I tried to modify this example: http://www.boost.org/doc/libs/1_34_0/libs/graph/example/dijkstra-example.cpp to create the graph in a clearer fashion: http://codepad.org/DDKs45oe However, I now get compiler errors inside dijkstra_shortest_paths.hpp Can anyone see where I have gone wrong? Also, I don't really understand the "distances and parents" output - I just want to know the shortest path between two vertices. In fact I don't even see the start and end vertices specified in the original example? Thanks, David
Hi, On Tuesday, 7. June 2011 00:32:33 David Doria wrote:
I tried to modify this example:
http://www.boost.org/doc/libs/1_34_0/libs/graph/example/dijkstra-example.cp p
to create the graph in a clearer fashion: http://codepad.org/DDKs45oe
However, I now get compiler errors inside dijkstra_shortest_paths.hpp
Can anyone see where I have gone wrong?
Was not yet able to look at it.
Also, I don't really understand the "distances and parents" output - I just want to know the shortest path between two vertices. In fact I don't even see the start and end vertices specified in the original example?
You should perhaps have a look at the description of this function of the boost-library again, where it says: Dijkstra's algorithm finds all the shortest paths from the source vertex to every other vertex by iteratively ``growing'' the set of vertices S to which it knows the shortest path. s. http://www.boost.org/doc/libs/1_34_0/libs/graph/doc/dijkstra_shortest_paths.... This basically means that you only need to specify the source vertex (called "s" in the example), and no end vertex. To get your shortest path, you would simply start with your end-vertex of choice, go to is predecessor, to the predecessor of the predecessor and so on until you find your start-vertex (this is called backtracking, IIRC). Here again, I would suggest you to read the documentation again (s. above)
Thanks,
David _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hope that helps. Best, Cedric
On Tuesday, 7. June 2011 00:32:33 David Doria wrote:
I tried to modify this example:
http://www.boost.org/doc/libs/1_34_0/libs/graph/example/dijkstra-example.cp p
to create the graph in a clearer fashion: http://codepad.org/DDKs45oe
However, I now get compiler errors inside dijkstra_shortest_paths.hpp
I am not absolutely sure about this, but it might be related to the fact that undirected_graph uses listS and not vecS as vertex-container. The problem here, then again, is that the algorithm can not use indices. And that seems to be exactly what it does, when simply providing vectors to store the predecessors and distances. This might be solved by either using your own UndirectedGraph definition with vecS as vertex-container or by providing an iterator_property_map which automatically wraps vertex_descriptor to an index and then writes to the vector. This example could be handy in this context: http://www.boost.org/doc/libs/1_37_0/libs/property_map/iterator_property_map... In case you need some advice on this, please let us/me know.
Can anyone see where I have gone wrong?
Also, I don't really understand the "distances and parents" output - I just want to know the shortest path between two vertices. In fact I don't even see the start and end vertices specified in the original example?
Thanks,
David _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Best, Cedric
I tried to modify this example: http://www.boost.org/doc/libs/1_34_0/libs/graph/example/dijkstra-example.cpp to create the graph in a clearer fashion: http://codepad.org/DDKs45oe However, I now get compiler errors inside dijkstra_shortest_paths.hpp Can anyone see where I have gone wrong?
The example assumes that vertices are stored in a vector,so that the vertex_descriptor type is unsigned int. This compiles for me: http://codepad.org/7lFgHka9 can't really say much more... Anders
On Tue, Jun 7, 2011 at 3:57 PM, Anders Wallin
I tried to modify this example: http://www.boost.org/doc/libs/1_34_0/libs/graph/example/dijkstra-example.cpp to create the graph in a clearer fashion: http://codepad.org/DDKs45oe However, I now get compiler errors inside dijkstra_shortest_paths.hpp Can anyone see where I have gone wrong?
Thanks all, Here are some working examples if anyone else is interested: http://programmingexamples.net/index.php?title=CPP/Boost/BGL/DijkstraDirecte... http://programmingexamples.net/index.php?title=CPP/Boost/BGL/DijkstraUndirec... http://programmingexamples.net/index.php?title=CPP/Boost/BGL/DijkstraCompute... David
participants (3)
-
Anders Wallin
-
Cedric Laczny
-
David Doria