|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.upc.dama.dex.tasks.Task
edu.upc.dama.dex.tasks.CompositeTask
edu.upc.dama.dex.algorithms.ShortestPath
edu.upc.dama.dex.algorithms.SinglePairShortestPath
edu.upc.dama.dex.algorithms.SinglePairShortestPathDijkstra
public class SinglePairShortestPathDijkstra
This class can be used to solve the single-pair shortest path problem in a weighted graph.
Concretely, it consists in finding a path between two nodes with the condition that the sum of the weights of the edges which belong to the path is minimized. This implementation is based on the Dijkstra algorithm.
It is possible to set some restrictions after constructing a new instance of this class and before running it in order to limit the results. Those restrictions are:
ShortestPath.setMaximumHops(int maxhops) method.
SinglePairShortestPathDijkstra.addWeightedEdge(int edgetype, short navigation, long attributetype)
for adding one edge type, its navigation and its attribute identifier.
Navigation
There are three kinds of edge navigation:
Algorithm.NAVIGATION_FORWARD: Allows to forward traverse edges.
Algorithm.NAVIGATION_BACKWARD: Allows to backward traverse edges.
Algorithm.NAVIGATION_UNDIRECTED: Allows to traverse edges in both directions.
SinglePairShortestPathDijkstra.getCost() method.
SinglePairShortestPath.getPathAsNodes() method.
SinglePairShortestPath.getPathAsEdges() method.
edu.upc.dama.dex.algorithms for further information related
to how to use this class.
NOTE: It is required to indicate the set of edge types before running this algorithm.
| Field Summary |
|---|
| Fields inherited from interface edu.upc.dama.dex.algorithms.Algorithm |
|---|
NAVIGATION_BACKWARD, NAVIGATION_FORWARD, NAVIGATION_UNDIRECTED |
| Constructor Summary | |
|---|---|
SinglePairShortestPathDijkstra(Graph graph,
long source,
long dest)
Creates a new instance of SinglePairShortestPathDijkstra. |
|
| Method Summary | |
|---|---|
void |
addWeightedEdge(int edgetype,
short navigation,
long attributetype)
Adds an edge type, its navigation and its attribute containing the weight in order to restrict the set of edge types allowed and their direction while traversing the graph to find the path. |
void |
close()
Closes the instance. |
java.lang.Double |
getCost()
Returns the cost, that is, the sum of the weights of the edges which belong to the path. |
void |
run()
Runs the algorithm in order to solve the shortest path problem. |
| Methods inherited from class edu.upc.dama.dex.algorithms.SinglePairShortestPath |
|---|
existsShortestPath, getPathAsEdges, getPathAsNodes |
| Methods inherited from class edu.upc.dama.dex.algorithms.ShortestPath |
|---|
setMaximumHops |
| Methods inherited from class edu.upc.dama.dex.tasks.CompositeTask |
|---|
cancel, execute, init |
| Methods inherited from class edu.upc.dama.dex.tasks.Task |
|---|
main |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SinglePairShortestPathDijkstra(Graph graph,
long source,
long dest)
SinglePairShortestPathDijkstra. After creating
this instance is required to indicate the set of edge types which will be
navigated through while traversing the graph in order to find the path.
graph - Graph on which the path will be found.source - The node identifier which identifies the source node at
which the algorithm execution will start.dest - The node identifier which identifies the destination node at
which the algorithm execution will end.| Method Detail |
|---|
public void addWeightedEdge(int edgetype,
short navigation,
long attributetype)
edgetype - The edge type to restrict the set of edges allowed
while traversing the graph during the execution of this algorithm.navigation - The direction that has to be followed while traversing
each edge of the given edge type during the execution of this algorithm.
It must be Algorithm.NAVIGATION_BACKWARD, Algorithm.NAVIGATION_FORWARD or
Algorithm.NAVIGATION_UNDIRECTED.attributetype - The attribute identifier of the given edge type
which contains the weight value.public java.lang.Double getCost()
-1 .
public void close()
ShortestPathOnce executed, the instance becomes invalid.
close in class ShortestPath
public void run()
throws java.lang.Throwable
ShortestPathThis method can be called only once.
run in class ShortestPathjava.lang.Throwable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||