V
 the graph vertex typeE
 the graph edge typepublic class KShortestPaths<V,E> extends Object implements KShortestPathAlgorithm<V,E>
The algorithm is a variant of the BellmanFord algorithm but instead of only storing the best path it stores the "k" best paths at each pass, yielding a complexity of O(k*n*(m^2)) where m is the number of edges and n is the number of vertices.
Constructor and Description 

KShortestPaths(Graph<V,E> graph,
int k)
Constructs an object to compute ranking shortest paths in a graph.

KShortestPaths(Graph<V,E> graph,
int k,
int nMaxHops)
Constructs an object to calculate ranking shortest paths in a graph.

KShortestPaths(Graph<V,E> graph,
int k,
int nMaxHops,
PathValidator<V,E> pathValidator)
Constructs an object to calculate ranking shortest paths in a graph.

KShortestPaths(Graph<V,E> graph,
int k,
PathValidator<V,E> pathValidator)
Constructs an object to compute ranking shortest paths in a graph.

Modifier and Type  Method and Description 

List<GraphPath<V,E>> 
getPaths(V startVertex,
V endVertex)
Returns the k shortest simple paths in increasing order of weight.

public KShortestPaths(Graph<V,E> graph, int k)
graph
 graph on which shortest paths are searchedk
 number of paths to be computedpublic KShortestPaths(Graph<V,E> graph, int k, PathValidator<V,E> pathValidator)
graph
 graph on which shortest paths are searched.k
 number of paths to be computed.pathValidator
 the path validator to useIllegalArgumentException
 if k is negative or 0.public KShortestPaths(Graph<V,E> graph, int k, int nMaxHops)
graph
 graph on which shortest paths are searchedk
 number of ranking paths between the start vertex and an end vertexnMaxHops
 maximum number of edges of the calculated pathsIllegalArgumentException
 if k is negative or 0.IllegalArgumentException
 if nMaxHops is negative or 0.public KShortestPaths(Graph<V,E> graph, int k, int nMaxHops, PathValidator<V,E> pathValidator)
graph
 graph on which shortest paths are searchedk
 number of ranking paths between the start vertex and the end vertexnMaxHops
 maximum number of edges of the calculated pathspathValidator
 the path validator to useIllegalArgumentException
 if k is negative or 0.IllegalArgumentException
 if nMaxHops is negative or 0.public List<GraphPath<V,E>> getPaths(V startVertex, V endVertex)
getPaths
in interface KShortestPathAlgorithm<V,E>
startVertex
 source vertex of the calculated paths.endVertex
 target vertex of the calculated paths.IllegalArgumentException
 if the graph does not contain the startVertex or the
endVertexIllegalArgumentException
 if the startVertex and the endVertex are the same verticesCopyright © 2017. All rights reserved.