Bellman-Ford shortest paths using boost C++
Algorithm for the single-source shortest paths problem for a graph with both positive and negative edge weights.
- instance of class graph
- character: node name for start of path
This function interfaces to the Boost graph library C++ routines for Bellman-Ford shortest paths. Choose the appropriate algorithm to calculate the shortest path carefully based on the properties of the given graph. See documentation on Bellman-Ford algorithm in Boost Graph Library for more details.
A list with elements:
- all edges minimized
- true if all edges are minimized, false otherwise.
- The vector of distances from
startto each node of
Infwhen there is no path from
- A vector of indices
nodes(g)) of predecessors corresponding to each node on the path from that node back to
. For example, if the
element one of this vector has value
- The start node that was supplied in the call to
10, that means that the predecessor of node
10. The next predecessor is found by examining
Boost Graph Library ( www.boost.org/libs/graph/doc/index.html )
The Boost Graph Library: User Guide and Reference Manual; by Jeremy G. Siek, Lie-Quan Lee, and Andrew Lumsdaine; (Addison-Wesley, Pearson Education Inc., 2002), xxiv+321pp. ISBN 0-201-72914-8
con <- file(system.file("XML/conn2.gxl",package="RBGL"), open="r") dd <- fromGXL(con) close(con) bellman.ford.sp(dd) bellman.ford.sp(dd,nodes(dd))