* pr
edecessor_map=None, class boost::vector_property_map
{lvalu
e} weight_map, class boost::python::api::object visitor=None, class
boost::vecto
r_property_map
Hi,
I can't seem to use dijkstra_shortest_paths as I think I should via the
python bindings. It works fine when I pass a weight_map and
predecessor_map. What I want to do is to pass a predecessor_map and a
distance_map. Unfortunately boost.python can't convert the arguments.
I'm using a bgl that says bgl.__version__ = '1.0' although I haven't
updated it from SVN recently.
This works:
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
)
This doesn't work:
import boost.graph as bgl
graph = bgl.Graph()
a = graph.add_vertex()
b = graph.add_vertex()
e = graph.add_edge(a, b)
distances = graph.add_edge_property('float')
predecessors = graph.add_vertex_property('vertex')
bgl.dijkstra_shortest_paths(
graph,
a,
predecessor_map = predecessors,
distance_map = distances
)
This is the error I get:
: Python argument types in
boost.graph._graph.dijkstra_shortest_paths(Graph, Vertex)
did not match C++ signature:
dijkstra_shortest_paths(class
boost::graph::python::basic_graph<struct boost
::bidirectionalS> graph, struct
boost::graph::python::basic_descriptor root_vertex, class
boost::vector_property_map,str
uct boost::graph::python::basic_index_map,struct
boost::adj_list_vertex_prope
rty_map,struct boost::property,struct
boost::no_property,struct boos
t::listS>,unsigned int,unsigned int const &,enum boost::vertex_index_t>
python::basic_index_map,struct
boost::adj_list_vertex_property_map,struct boost::property,struct boost::no_property,struct
boost::listS>,unsigned
int,unsigned int const &,enum boost::vertex_index_t> > > *
distance_map=None, c
lass boost::vector_property_map,struct
boost::bidirectionalS>,struc
t boost::adj_list_edge_property_map const ,enum boost::edge_index_t> >
directionalS>,struct boost::adj_list_vertex_property_map,struct boost::property,struct boost::no_property,struct boost::listS>,unsigned
int,unsigned
int const &,enum boost::vertex_index_t> > > * color_map=None)
dijkstra_shortest_paths(class
boost::graph::python::basic_graph<struct boost
::undirectedS> graph, struct boost::graph::python::basic_descriptor root_vertex, class
boost::vector_property_map,struct boost
::graph::python::basic_index_map,struct
boost::adj_list_vertex_property_map,struct boost::property,struct boost::no_property,struct
boost::listS>,unsig
ned int,unsigned int const &,enum boost::vertex_index_t> > > *
predecessor_map=N
one, class boost::vector_property_map,struct boost::adj_list_vertex_property_map,stru
ct boost::property,struct boost::no_property,struct boost::listS>,unsigned int,unsigned
int con
st &,enum boost::vertex_index_t> > > * distance_map=None, class
boost::vector_pr
operty_map,struct boost::undirectedS>,struct
boost::adj_list_edge_prop
erty_map const ,enum boost::edge_index_t> > > {lvalue} weight_map, class
boost::py
thon::api::object visitor=None, class boost::vector_property_map,struct
boost::adj_l
ist_vertex_property_map,struct
boost::property,struct
boost::no_propert
y,struct boost::listS>,unsigned int,unsigned int const &,enum
boost::vertex_inde
x_t> > > * color_map=None)
For reference here is the docstring bgl gives me:
Type: function
Base Class:
String Form:
Namespace: Interactive
Docstring:
dijkstra_shortest_paths(graph, root_vertex, predecessor_map = None,
distance_map = None, weight_map = None,
visitor = None)
Computes the shortest paths from the root vertex to every other vertex
in a graph.
Parameters:
graph the graph on which to compute shortest paths will
run. It may be either a directed or undirected graph.
root_vertex the starting vertex for the shortest-path search.
predecessor_map a vertex -> vertex map that stores the predecessor of
each vertex in the shortest paths tree. From a given
vertex, one can follow the predecessor_map back to
the root_vertex to reconstruct the shortest path.
distance_map a vertex -> float map that stores the distance from
the root_vertex to each vertex in the tree. A
distance of infinity in this property map indicates
that the vertex is unreachable from the root_vertex.
weight_map an edge -> float map that stores the weight of each
edge in the graph. Negative edge weights are not
permitted. If no weight map is provided, each edge
will be assumed to have a weight of 1.0.
visitor a visitor that will receive events as the
shortest-paths computation progresses. Typically this
visitor should be derived from
boost.graph.dijkstra_visitor.
See also:
bellman_ford_shortest_paths
dag_shortest_paths
dijkstra_visitor
Complete C++ documentation is available at:
http://www.boost.org/libs/graph/doc/dijkstra_shortest_paths.html
Any help appreciated,
John.