Package org.jgrapht.alg
Class FloydWarshallShortestPaths<V,E>
java.lang.Object
org.jgrapht.alg.FloydWarshallShortestPaths<V,E>
The
Floyd-Warshall algorithm finds all shortest paths (all n^2 of them) in
O(n^3) time. This also works out the graph diameter during the process.
- Author:
- Tom Larkworthy, Soren Davidsen invalid input: '<'soren@tanesha.net>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublegetGraph()getShortestPath(V a, V b) Get the shortest path between two vertices.Get shortest paths from a vertex to all other vertices in the graph.intdoubleshortestDistance(V a, V b) Get the length of a shortest path.
-
Constructor Details
-
FloydWarshallShortestPaths
-
-
Method Details
-
getGraph
- Returns:
- the graph on which this algorithm operates
-
getShortestPathsCount
public int getShortestPathsCount()- Returns:
- total number of shortest paths
-
shortestDistance
Get the length of a shortest path.- Parameters:
a- first vertexb- second vertex- Returns:
- shortest distance between a and b
-
getDiameter
public double getDiameter()- Returns:
- the diameter (longest of all the shortest paths) computed for the graph
-
getShortestPath
Get the shortest path between two vertices. Note: The paths are calculated using a recursive algorithm. It *will* give problems on paths longer than the stack allows.- Parameters:
a- From verticeb- To vertice- Returns:
- the path, or null if none found
-
getShortestPaths
Get shortest paths from a vertex to all other vertices in the graph.- Parameters:
v- the originating vertex- Returns:
- List of paths
-