[pyton] how to use dijkstra's shortest path algorithm

Neeraj Shah <[email protected]>
Newsgroups gmane.comp.lib.boost.langbinding
Message-ID <[email protected]>
Hi everyone,

I am completely new to Boost, and have been playing with it through the python bindings, but I'm getting a bit confused. 

What I'm trying to do is use dijkstra's shortest path algorithm (with predecessor) on a graph I'm reading in from a graphviz file. My code is as below:

import boost.graph as bgl

#Create a new graph from the graphviz file
graph = bgl.Graph.read_graphviz('code/mst.dot')
#try to get shortest path
min_paths = bgl.dijkstra_shortest_paths(graph,graph.vertices.next(),predecessorMap,distanceMap)

which is the way variables should be entered according to the documentation.

dijkstra_shortest_paths(graph, root_vertex, predecessor_map = None, 

                        distance_map = None, weight_map = None, 

                        visitor = None)

I'm not completely sure what I'm doing wrong. Basically, I would like to get the predecessors and then print them out to screen.

And finally, how do you actually access a single vertex. Say I want vertex one of my graph, or vertex two or whatever. Do I have to iterate over until I get there or is there an easier way?

Thanks (sorry is this has already been posted. I searched but couldn't find a previous posting)

Neeraj








	
	
		
___________________________________________________________ 
New Yahoo! Mail is the ultimate force in competitive emailing. Find out more at the Yahoo! Mail Championships. Plus: play games and win prizes. 
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Boost-langbinding mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-langbinding
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.