V
- Vertex typeE
- Edge typepublic static class GraphUtils.YenAlgorithm<V,E>
extends Object
Class to calculate the (loopless) k-shortest paths between a node pair using Yen's algorithm.
Reference: J.Y. Yen, "Finding the K Shortest Loopless Paths in a Network," <i>Management Science</i>, vol. 17, no. 11, pp. 712-716, Jul. 1971
Constructor and Description |
---|
GraphUtils.YenAlgorithm(edu.uci.ics.jung.graph.Graph<V,E> graph,
org.apache.commons.collections15.Transformer<E,Double> nev)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
acceptPath(GraphUtils.GraphPath<E> candidate)
Indicates whether a path is valid.
|
boolean |
compareCandidateToShortestPath(GraphUtils.GraphPath<E> candidate,
GraphUtils.GraphPath<E> shortestPath)
Indicates whether a path is valid when compared to the shortest path.
|
List<List<E>> |
getPaths(V startVertex,
V endVertex,
int k)
Returns the (loopless) k-shortest simple paths in increasing order of weight.
|
public GraphUtils.YenAlgorithm(edu.uci.ics.jung.graph.Graph<V,E> graph, org.apache.commons.collections15.Transformer<E,Double> nev)
graph
- Graph on which shortest paths are searchednev
- The class responsible for returning weights for edgespublic boolean acceptPath(GraphUtils.GraphPath<E> candidate)
compareCandidateToShortestPath()
method.
method can be used to compare current candidate path with the shortest path.candidate
- Candidate pathtrue
must be accepted. Otherwise, false
public boolean compareCandidateToShortestPath(GraphUtils.GraphPath<E> candidate, GraphUtils.GraphPath<E> shortestPath)
candidate
- Candidate pathshortestPath
- true
must be accepted. Otherwise, false
public List<List<E>> getPaths(V startVertex, V endVertex, int k)
Returns the (loopless) k-shortest simple paths in increasing order of weight.
Important: If only n < k paths can be found, only such n paths will be returned.
startVertex
- Start vertex of the calculated pathsendVertex
- Target vertex of the calculated pathsk
- Number of paths to be computed