Boost logo

Boost Users :

From: John Reid (j.reid_at_[hidden])
Date: 2006-11-30 11:47:46


Hi,

This works for me:

import boost.graph as bgl

graph = bgl.Graph()
a = graph.add_vertex()
b = graph.add_vertex()
e = graph.add_edge(a, b)

weights = graph.add_edge_property('integer')
weights[e] = 5

predecessors = graph.add_vertex_property('vertex')
bgl.dijkstra_shortest_paths(
        graph,
        a,
        predecessor_map = predecessors,
        weight_map = weights
)

Hope that helps,
John.

Hugo Ferreira wrote:
> HI there,
>
> I'm trying to use the BGL bindings for python found here:
> http://www.osl.iu.edu/~dgregor/bgl-python/
>
> The problem is that I can't seem to understand how the
> dijkstra_shortest_paths() and the corresponding graph works. My code,
> so far, is like this:
>
> ---8<---8<---
>
> import boost as bgl
>
> graph = bgl.Graph()
> a = graph.add_vertex()
> b = graph.add_vertex()
> e = graph.add_edge(a, b)
>
> weights = graph.edge_property_map('integer')
> weights[e] = 5
> graph.edge_properties['weight'] = weights
>
> boost.dijkstra_shortest_paths(graph, a)
>
> ---8<---8<---
>
> Which, of course, complains about the dijkstra_shortest_paths function
> signature. Can anyone please provide me an working example of setting
> up a graph and calling this function? I basically need the shortest
> path from vertex A to vertex B.
>
> Thanks in advance,
>
> Hugo Ferreira
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net