CoinShortestPath
Class that implements Dijkstra's algorithm for finding the shortest paths between nodes in a graph.
Class that implements Dijkstra's algorithm for finding the shortest paths between nodes in a graph.
Public Methods
CoinShortestPath
Default constructor.
CoinShortestPath(size_t nodes, size_t arcs, const size_t * arcStart, const size_t * toNode, const double * dist)
Parameters:
nodes(size_t) - number of nodes in the grapharcs(size_t) - number of arcs in the grapharcStart(const size_t *) - array containing the start position of the neighbors of each nodetoNode(const size_t *) - array containing the neighbors of all nodesdist(const double *) - array containing the distance between each node and its neighbors.
~CoinShortestPath
Destructor.
~CoinShortestPath()
find
Execute the shortest path finder using Dijkstra's algorithm.
void find(const size_t origin)
Parameters:
origin(const size_t)
find
Execute the shortest path finder using the Dijkstra algorithm.
void find(const size_t origin, const size_t destination)
Parameters:
origin(const size_t)destination(const size_t)
path
Fill array indexes with all previous nodes which should be steped to arrive at a given node (this node is not included).
size_t path(size_t toNode, size_t * indexes)
Parameters:
toNode(size_t)indexes(size_t *)
numNodes
Return the number of nodes in the graph.
size_t numNodes()
numArcs
Return the number of arcs in the graph.
size_t numArcs()
distance
Return the length of the shortest path from the origin node (passed in method find) to node.
double distance(size_t node)
Parameters:
node(size_t)
previous
Return the previous node of a given node in the shortest path.
size_t previous(size_t node)
Parameters:
node(size_t)
previous
Return an array containing the previous nodes which should be steped to arrive at a given node.
const size_t * previous()
Source
Header: layer-0/CoinUtils/src/CoinShortestPath.hpp