shortest_path and pred_map

Hello,

Here is a code snippet where I try to use the shortest_path function with a
precomputed predecessor_map.

targets = range(1,10)

source = 0

distances_in, pred_map = shortest_distance(graph,
                                           source=source,
                                           target=targets,
                                           weights=graph.ep[EDGE_LEN],
                                           pred_map=True)

inward_path = shortest_path(graph,
                            source=source,
                            target=targets[5],
                            pred_map=pred_map)

To run that code ends in:

  File "/usr/lib/python2.7/dist-packages/graph_tool/topology/__init__.py",
line 1348, in shortest_path
    if pred_map[target] == int(target): # no path to target
  File "/usr/lib/python2.7/dist-packages/graph_tool/__init__.py", line 438,
in __getitem__
    return self.__map[self.__key_trans(k)]
Boost.Python.ArgumentError: Python argument types in
    VertexPropertyMap<int64_t>.__getitem__(VertexPropertyMap<int64_t>,
numpy.int64)
did not match C++ signature:

__getitem__(graph_tool::PythonPropertyMap<boost::checked_vector_property_map<long,
boost::typed_identity_property_map<unsigned long> > > {lvalue},
graph_tool::PythonVertex)

How could i circumvent that issue ?
Thanks!
François.

attachment.html (3.48 KB)

Any hints on this? I'm kind of stuck.

Best,
François.

2015-07-08 16:32 GMT+02:00 François Kawala <francois.kawala(a)gmail.com>:

attachment.html (4.08 KB)

You have to pass vertex descriptors, not integers. For instance, just
use graph.vertex(source) instead of source. Same thing for target.

Best,
Tiago

Great! I was fooled by shortest_distance that expects int.
Thanks,
F.

2015-07-09 14:54 GMT+02:00 Tiago de Paula Peixoto <tiago(a)skewed.de>:

attachment.html (3.85 KB)