我有一个用邻接矩阵表示的图,我想找出两个节点之间的最短路径。该图是加权的。我想使用BFS算法,我已经尝试过了,但我没有想法了。这是我的代码,如果你能帮我的话。 private static int[][] adjacency = new int [4][4]; for (int i=0;i<n;i++)
我创建了一个类来实现图上的Dijkstra算法。public class Dijkstra<V, E extends DoubleSupplier> {}public class DijkstraTest {
Dijkstra<String, Integer> dijkstra = new Dijkstr
b = new Dijkstra(temp, start, target, p);}Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:5
Vertex argTarget, double argWeight) { this.weight = argWeight;Dijkstra.javadijkstra = new Dijkstra();
at java.util.Arrays.copyOf(Arrays.java:2760)
at java.util.Ar