Ticket #4731 (closed Bugs: fixed)
Documentation for dijkstra shortest path is wrong
|Reported by:||Markus Pilman <mpilman@…>||Owned by:||asutton|
|Milestone:||To Be Determined||Component:||graph|
|Keywords:||bgl graph dijaksta shortest path minimum spanning tree||Cc:|
In the documentation for dijkstra_shortest_paths, you can read:
"The predecessor map records the edges in the minimum spanning tree. Upon completion of the algorithm, the edges (p[u],u) for all u in V are in the minimum spanning tree."
I would say, that this is wrong: Dijkstra won't give you a minimum spanning tree in all cases.
One counterexample would be a undirected graph with the vertices (0,1,2) and the following edges (format is start,point, endpoint, weight):
(0, 1, 2) (0, 2, 3) (1, 2, 4)
This graph has only one minimum spanning tree with the predecessors map (2,0,2) - which is what you get with prim. If you execute dijkstra shortest path on this graph, you will get (2,2,2) - and this is not a minimum spanning tree (since the weight of this tree is 7, while the weight of the minimum spanning tree is 5).
Find attached an example which calculates both algorithms on these two graphs. I really think this should be fixed in the documentation.
- Status changed from closed to reopened
- Resolution fixed deleted
- Status changed from reopened to closed
- Resolution set to fixed