V - the graph vertex typeE - the graph edge typepublic class BhandariKDisjointShortestPaths<V,E>
extends java.lang.Object
The algorithm is running $k$ sequential Bellman-Ford iterations to find the shortest path at each step. Hence, yielding a complexity of $k$*O(Bellman-Ford).
| Modifier and Type | Field and Description |
|---|---|
protected Graph<V,E> |
originalGraph |
protected java.util.Set<E> |
overlappingEdges |
protected java.util.List<java.util.List<E>> |
pathList |
protected Graph<V,E> |
workingGraph
Graph on which shortest paths are searched.
|
| Constructor and Description |
|---|
BhandariKDisjointShortestPaths(Graph<V,E> graph)
Creates a new instance of the algorithm.
|
| Modifier and Type | Method and Description |
|---|---|
protected GraphPath<V,E> |
calculateShortestPath(V startVertex,
V endVertex)
Calculates the shortest paths for the current iteration.
|
java.util.List<GraphPath<V,E>> |
getPaths(V startVertex,
V endVertex,
int k)
Returns the $k$ shortest simple paths in increasing order of weight.
|
protected void |
transformGraph(java.util.List<E> previousPath)
Prepares the working graph for next iteration.
|
protected Graph<V,E> workingGraph
protected java.util.List<java.util.List<E>> pathList
protected java.util.Set<E> overlappingEdges
protected Graph<V,E> originalGraph
public BhandariKDisjointShortestPaths(Graph<V,E> graph)
graph - graph on which shortest paths are searched.java.lang.IllegalArgumentException - if the graph is null.java.lang.IllegalArgumentException - if the graph is undirected.java.lang.IllegalArgumentException - if the graph is not simple.protected void transformGraph(java.util.List<E> previousPath)
calculateShortestPath(V, V) call.previousPath - the path found at the previous iteration.protected GraphPath<V,E> calculateShortestPath(V startVertex, V endVertex)
startVertex - the start vertexendVertex - the end vertexpublic java.util.List<GraphPath<V,E>> getPaths(V startVertex, V endVertex, int k)
getPaths in interface KShortestPathAlgorithm<V,E>startVertex - source vertex of the calculated paths.endVertex - target vertex of the calculated paths.k - the number of shortest paths to returnjava.lang.IllegalArgumentException - if the graph does not contain the startVertex or the
endVertexjava.lang.IllegalArgumentException - if the startVertex and the endVertex are the same verticesjava.lang.IllegalArgumentException - if the startVertex or the endVertex is nullCopyright © 2019. All Rights Reserved.