Talk:Dijkstra's algorithm (Java)

From LiteratePrograms

Jump to: navigation, search

Is there any way to find all of the shortest path between all of the nodes? I tried to do this:

computePaths(v0);
        for (Vertex v : vertices)
	{
	    System.out.println("Distance to " + v + ": " + v.minDistance);
	    List<Vertex> path = getShortestPathTo(v);
	    System.out.println("Path: " + path);
	}
computePaths(v1);
        for (Vertex v : vertices)
	{
	    System.out.println("Distance to " + v + ": " + v.minDistance);
	    List<Vertex> path = getShortestPathTo(v);
	    System.out.println("Path: " + path);
	}
computePaths(v2);
        for (Vertex v : vertices)
	{
	    System.out.println("Distance to " + v + ": " + v.minDistance);
	    List<Vertex> path = getShortestPathTo(v);
	    System.out.println("Path: " + path);
	}
               ...

But it doesn't work for me and I got several 0 for the next stage. --irsdl 13:38, 26 March 2009 (MDT)

Personal tools