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.
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@gmail.com>:
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.
-- François Kawala
On 09.07.2015 10:46, François Kawala wrote:
2015-07-08 16:32 GMT+02:00 François Kawala <francois.kawala@gmail.com <mailto:francois.kawala@gmail.com>>:
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 ?
You have to pass vertex descriptors, not integers. For instance, just use graph.vertex(source) instead of source. Same thing for target. Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
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@skewed.de>:
On 09.07.2015 10:46, François Kawala wrote:
2015-07-08 16:32 GMT+02:00 François Kawala <francois.kawala@gmail.com <mailto:francois.kawala@gmail.com>>:
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 ?
You have to pass vertex descriptors, not integers. For instance, just use graph.vertex(source) instead of source. Same thing for target.
Best, Tiago
-- Tiago de Paula Peixoto <tiago@skewed.de>
_______________________________________________ graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/mailman/listinfo/graph-tool
-- François Kawala
participants (2)
-
François Kawala -
Tiago de Paula Peixoto