|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Observable fr.inria.opengve.bridge.algorithms.StepAlgo<V,E> fr.inria.opengve.bridge.algorithms.common.shortestPath.KShortestPaths<V,E,G>
public abstract class KShortestPaths<V,E extends Link<V>,G extends Graph<V,E>>
This class solve the problem of k-shortest path (not disjoint). It uses the algorithm found in the book "Routing, Flow and Capacity Design in Communication and Computer Networks" by michal Pioro and Deepankar.
The algorithm is based on the paper: C. J. McCallum, An Algorithm for finding the k shortest paths in a network. Bell laboratories, Technical Memorandum, 1973; M. M. B. Pascoal, V. Captivo, and J. C. N. Climaco, An algorithm for ranking quickest simple paths, Computers & Operations Research, 2003. The original idea is from: J. Y. Yen, Finding the k shortest loopless paths in a network, Management Science, 17:712-716, 1971.
This algorithm uses DijkstraAdvanced to compute the shortest paths. It reads
the lenght (or weight) of arcs getting a value stored in a
AbstractScalar
. The value used to compute
path weight is load from the map passed as constructor argument. You can set
the name (setDistanceContext(Object)
) and the context (setDistanceContext(Object)
)
used to load this value.
When the computation is done, you can ask the number of found paths (which is
inferior or equal to requested number of paths) with the method
numberOfComputedPaths()
. Then, you can get the paths with
getShortestPath(int)
. If the requested k-th path does not exist, it
will return a null pointer.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class fr.inria.opengve.bridge.algorithms.StepAlgo |
---|
StepAlgo.StepAlgoMessage, StepAlgo.StepAlgoMessageType |
Field Summary | |
---|---|
int |
numberOfComputedPaths
The current number of computed paths. |
Constructor Summary | |
---|---|
KShortestPaths(G g,
Map distance)
Constructor of KShortestPaths. |
|
KShortestPaths(G g,
Map distance,
boolean stepMode)
This constructor permit to specify the stepMode of the algorithm. |
Method Summary | |
---|---|
void |
computeShortestPath(V s,
V t,
int k)
Compute k shortest path between s and t. |
protected abstract CopyGraph<V,E,G> |
createCopyGraph()
Create a new copy tool. |
protected abstract DijkstraAdvanced<V,E,G> |
createDijkstraAdvanced(G g,
V destination)
Create an algorithms that compute shortest path between source and destination. |
protected abstract Path<V,E> |
createPath()
Create a new path. |
double |
getDistance(int k)
Returns the weight of the k-th path. |
Path<V,E> |
getShortestPath(int k)
Return the k-th path computed. |
int |
numberOfComputedPaths()
Return the number of computed paths. |
void |
run()
Runs the computation of k shortests paths between s and t. |
void |
setDistanceContext(java.lang.Object context)
Set the context used to load distance of edges in the map. |
void |
setDistanceName(java.lang.String name)
Set the name used to load distance of edges in the map. |
void |
setEndsOfPath(V s,
V t)
Set the ends of computed paths. |
void |
setInfiniteDistance(AbstractScalar infinite)
Set the distance used as infinite. |
void |
setNumberOfComputedPath(int k)
Set the number of paths that must be computed. |
Methods inherited from class fr.inria.opengve.bridge.algorithms.StepAlgo |
---|
ends, getDemoMode, getStepMode, isEnded, nextStep, notifyGraphDisplayRequest, notifyGraphDisplayRequest, notifyLabelEdgesRequest, notifyLabelVerticesRequest, pause, setPauseMode, setTime, start |
Methods inherited from class java.util.Observable |
---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int numberOfComputedPaths
Constructor Detail |
---|
public KShortestPaths(G g, Map distance)
g
- the graph on which we search paths.distance
- the map storing weight of each edges.public KShortestPaths(G g, Map distance, boolean stepMode)
g
- the graph to use to find paths.distance
- the map storing weight of each edges.stepMode
- The stepMode of the algorithms.Method Detail |
---|
protected abstract DijkstraAdvanced<V,E,G> createDijkstraAdvanced(G g, V destination)
g
- The graph.destination
- The destination of the path.
protected abstract CopyGraph<V,E,G> createCopyGraph()
protected abstract Path<V,E> createPath()
public void setDistanceName(java.lang.String name)
name
- The new name used to load distance of edges in the map.public void setDistanceContext(java.lang.Object context)
context
- The new context.public void setInfiniteDistance(AbstractScalar infinite)
infinite
- The new infinite distance.public void setNumberOfComputedPath(int k)
k
- The number of path that must be computed.public void setEndsOfPath(V s, V t)
s
- The first vertex of computed path in directed graph and one of two
ends in undirected one.t
- The last vertex of computed path in directed graph and one of two
ends in undirected one.public void computeShortestPath(V s, V t, int k)
s
- The begining of paths. Only sense with directed graph.t
- The end of paths. Only sense with directed graph.k
- The number of paths that msut be computed.public void run()
run
in interface java.lang.Runnable
run
in class StepAlgo<V,E extends Link<V>>
public Path<V,E> getShortestPath(int k)
k
- the number of the path (start at 0).
public int numberOfComputedPaths()
public double getDistance(int k)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |