Re: Way to print a route between two nodes
I don't know exactly how you are traversing those nodes in the path, - ie how do find the path -, but as far as I know you have to use a visitor with an algorithm such as dijisktra shortest paths, so you define the event point, on_finish_vertex for example where you want the visitor to be called. This algorithm also stores in a vector the minimum weight pahts encountered from an specific origin vertex so you can go over those paths from the last vertex to this origin. Hope to be of help ------------------------------ Message: 10 Date: Thu, 29 Jul 2004 15:33:34 +0200 From: Daniele Carlucci Subject: [Boost-users] Way to print a route between two nodes To: boost-users@lists.boost.org Message-ID: <4108FCAE.8040301@email.it> Content-Type: text/plain; charset=us-ascii; format=flowed Hi all, there is a way to print a route between two nodes? If I have for ie: 8 nodes. A possible route is 1->3->2->6->8 How can I print it? I have only seen that it's used the way to print for every node, all the nodes near that one. Thanks Daniele ------------------------------ ---------------------------------
On Jul 30, 2004, at 1:23 AM, Gustavo Sÿffffe1nchez wrote:
I don't know exactly how you are traversing those nodes in the path, - ie how do find the path -, but as far as I know you have to use a visitor with an algorithm such as dijisktra shortest paths, so you define the event point, on_finish_vertex for example where you want the visitor to be called. This algorithm also stores in a vector the minimum weight pahts encountered from an specific origin vertex so you can go over those paths from the last vertex to this origin.
The best way to get at the shortest paths is to provide a predecessor map. The documentation of dijkstra_shortest_paths says: "Also you can record the shortest paths tree in a predecessor map: for each vertex u in V, p[u] will be the predecessor of u in the shortest paths tree (unless p[u] = u, in which case u is either the source or a vertex unreachable from the source). In addition to these two options, the user can provide there own custom-made visitor that can takes actions during any of the algorithm's event points." Doug
participants (2)
-
Doug Gregor
-
Gustavo Sÿffffe1nchez