|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--mascoptLib.algos.abstractalgos.KShortestPath
Provides a simple algorithm to find the K shortest distance between all nodes
and the paths corresponding to theses nodes. We suppose that the graph contains
no negative cycle (with a negative cycle, you can reduce the length of the
path with no limits...)
Self-loops are allowed
This algorithm is made of three steps:
1)finding the shortest path between 2 nodes
2)erasing this path
3)finding the new shortest path between theses 2 nodes
There are two different ways of erasing a path (depending of the kind of paths we want
to find : disjoint or not)
DISTANCE_MAX
is a constant representing the maximum
distance beetween two nodes (modelize the infinite value)
WEIGHT
is a String allowing the access to the weight of an edge.
It requires the edge to use the setValue method with the string KShortestPath.POIDS
(equals to "poids"). You can change this value. If you use the GraphEditor software, you must
put the value of the edge to poids by default.
WARNING: you may be faced with a java.lang.OutOfMemoryError with big
graph. You can solve this problem by increasing the amount of memory used by the JVM.
By default, 64M are used for the virtual machine. By typing
"java -Xmx$$$m", you will launch the JVM with $$$M of memory, allowing to compute bigger graph.
getShortestPath
Field Summary | |
static String |
WEIGHT
|
Constructor Summary | |
KShortestPath(mascoptLib.abstractGraph.AbstractGraph g)
Construct a KShortestPath object that compute only the first shortest path |
|
KShortestPath(mascoptLib.abstractGraph.AbstractGraph g,
int k)
Default constructor. |
Method Summary | |
static int |
getPathLength(mascoptLib.abstractGraph.AbstractPath chain)
a static method to compute the length of an AbstractChain |
Vector |
getShortestPath(mascoptLib.abstractGraph.AbstractEdge e)
allow the user to get the kshortest path for a demand request by an edge. |
Vector |
getShortestPath(mascoptLib.abstractGraph.AbstractVertex src,
mascoptLib.abstractGraph.AbstractVertex dest)
allow the user to get the kshortest path between 2 nodes. |
Vector |
getShortestPath(mascoptLib.abstractGraph.AbstractVertex src,
mascoptLib.abstractGraph.AbstractVertex dest,
int j)
allow the user to get the kshortest path between 2 nodes. |
int[] |
getShortestPathLength(mascoptLib.abstractGraph.AbstractVertex src,
mascoptLib.abstractGraph.AbstractVertex dest)
allow the user to get the length of the kshortest path between 2 nodes you must have launched the run method before calling this method |
int |
getShortestPathLength(mascoptLib.abstractGraph.AbstractVertex src,
mascoptLib.abstractGraph.AbstractVertex dest,
int j)
allow the user to get the length of the kshortest path between 2 nodes you must have launched the run method before calling this method |
void |
run()
compute the k shortest path between each pairs of node |
void |
runNonDisjoint()
compute the k shortest path between each pairs of node but the paths obtained are non-disjoint |
void |
write(String file)
WARNING: this method is not implemented yet compute the k shortest path between each pairs of node but write the results in a file instead of writing them in memory |
void |
writenonDisjoint(String file)
WARNING: this method is not implemented yet compute the k shortest path (non-disjoint) between each pairs of node but write the results in a file instead of writing them in memory |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String WEIGHT
Constructor Detail |
public KShortestPath(mascoptLib.abstractGraph.AbstractGraph g, int k)
run
function to
compute the distances and path and then, get these results
via other access method of the class.
g
- the graph used by KShortestPath algorithmk
- the number of path we want to computepublic KShortestPath(mascoptLib.abstractGraph.AbstractGraph g)
g
- the graph used by KShortestPath algorithmKShortestPath(AbstractGraph g, int k)
Method Detail |
public void run()
run
in interface Runnable
public Vector getShortestPath(mascoptLib.abstractGraph.AbstractVertex src, mascoptLib.abstractGraph.AbstractVertex dest)
src
- AbstractNode the source nodedest
- AbstractNode the destination node
public Vector getShortestPath(mascoptLib.abstractGraph.AbstractVertex src, mascoptLib.abstractGraph.AbstractVertex dest, int j)
src
- AbstractNode the source nodedest
- AbstractNode the destination nodej
- int the rank of the path we want to get
public int[] getShortestPathLength(mascoptLib.abstractGraph.AbstractVertex src, mascoptLib.abstractGraph.AbstractVertex dest)
src
- AbstractNode the source nodedest
- AbstractNode the destination node
public int getShortestPathLength(mascoptLib.abstractGraph.AbstractVertex src, mascoptLib.abstractGraph.AbstractVertex dest, int j)
src
- AbstractNode the source nodedest
- AbstractNode the destination nodej
- int the rank of the path we want to get
public static int getPathLength(mascoptLib.abstractGraph.AbstractPath chain)
chain
- AbstractChain the path on which we want to find the length
public void write(String file)
file
- String the output filepublic void writenonDisjoint(String file)
file
- String the output filepublic void runNonDisjoint()
public Vector getShortestPath(mascoptLib.abstractGraph.AbstractEdge e)
e
- the edge considered for the path
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |