我有道路名称和连接
public static void inisial(ArrayList track)
{
String[] connected = {"B","C","D","K","L"};
information = new Street("A",connected);
track.add(information);
String[] connected = {"E","F","G","A"};
information = new Street("K",connected);
track.add(information);
String[] connected = {"H","I","J","A"};
information = new Street("L",connected);
track.add(information);
}
public static Street findStreet (String source, String destination)
{
for (int i = 0;i < track.size(); i++)
{
if(track.get(i).getNameStreet().equalsIgnoreCase(source))
{
first = i;
System.out.println(track.get(awal).getNameStreet());
for (int j = 0;j < track.get(awal).getConnected().length;j++)
{
next=i;
}
}
}
我如何获得A-J的路径?我正在尝试使用蚁群优化来找到最好的街道。有人可以帮我解决这个问题吗?或者你可能参考了蚁群优化以找到最好的街道。