edu.upc.dama.dex.algorithms
Class SinglePairShortestPath

java.lang.Object
  extended by edu.upc.dama.dex.tasks.Task
      extended by edu.upc.dama.dex.tasks.CompositeTask
          extended by edu.upc.dama.dex.algorithms.ShortestPath
              extended by edu.upc.dama.dex.algorithms.SinglePairShortestPath
All Implemented Interfaces:
Algorithm
Direct Known Subclasses:
SinglePairShortestPathBFS, SinglePairShortestPathDijkstra

public abstract class SinglePairShortestPath
extends ShortestPath

Any class implementing this abstract class can be used to solve the problem of 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.

Author:
Sparsity Technologies

Field Summary
 
Fields inherited from interface edu.upc.dama.dex.algorithms.Algorithm
NAVIGATION_BACKWARD, NAVIGATION_FORWARD, NAVIGATION_UNDIRECTED
 
Constructor Summary
SinglePairShortestPath(Graph graph, long source, long dest)
          Creates a new instance of SinglePairShortestPath.
 
Method Summary
 boolean existsShortestPath()
          Gets whether a shortest path has been found.
 long[] getPathAsEdges()
          Returns the shortest path found as a set of ordered edges between the source node and the destination node.
 long[] getPathAsNodes()
          Returns the shortest path found as a set of ordered nodes between the source node and the destination node.
 
Methods inherited from class edu.upc.dama.dex.algorithms.ShortestPath
close, run, 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

SinglePairShortestPath

public SinglePairShortestPath(Graph graph,
                              long source,
                              long dest)
Creates a new instance of SinglePairShortestPath.

Parameters:
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

existsShortestPath

public boolean existsShortestPath()
Gets whether a shortest path has been found.

Returns:
It returns true if a shortest path has been found, otherwise it returns false.

getPathAsNodes

public long[] getPathAsNodes()
Returns the shortest path found as a set of ordered nodes between the source node and the destination node.

Returns:
Array of ordered node identifiers contained in the shortest path. The first node identifier is the source node and the last node identifier is the destination node. If no shortest path has been found, it returns null .

getPathAsEdges

public long[] getPathAsEdges()
Returns the shortest path found as a set of ordered edges between the source node and the destination node.

Returns:
Array of ordered edge identifiers contained in the shortest path. The first edge identifier is the edge that has the source node as its source or target and the last node identifier is the edge that has the destination node as its source or target. If no shortest path has been found, it returns null .