Hello, 

The shortest_path and shortest_distance functions are fixed to be able to handle more than one target. In order to be be more explicit, I propose for those two functions to return a dictionary when there is more than one target. This dictionary would be keyed by target vertex. What do you think about that ? This behavior is implemented in https://github.com/Fkawala/graph-tool.

I did a minimal working example which is there: https://gist.github.com/Fkawala/afd0a666619c1d2716a5

I guess that next steps are (1) code review, and (2) performance and/or unit tests? Is that correct ?

Best,
François.


2015-04-22 10:37 GMT+02:00 Tiago Peixoto [via Main discussion list for the graph-tool project] <[hidden email]>:
On 22.04.2015 10:54, François wrote:

> Hello,
>
> I realize that my C++ skill aren't sufficient to produce quality /
> maintainable / efficient code for this feature. Would you take care of
> this ?
>
> I've update my github repo <https://github.com/Fkawala/gcloud-python>,
> it compiles but does not work.

>
> The current error stack is:
>
>     Traceback (most recent call last):
>       File "<stdin>", line 1, in <module>
>       File "/usr/lib/python2.7/dist-packages/graph_tool/topology/__init__.py", line 1337, in shortest_path
>         pred_map=True)[1]
>       File "/usr/lib/python2.7/dist-packages/graph_tool/topology/__init__.py", line 1263, in shortest_distance
>         dist_map = dist_map[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<int32_t>.__getitem__(VertexPropertyMap<int32_t>, tuple)
>     did not match C++ signature:
>         __getitem__(graph_tool::PythonPropertyMap<boost::checked_vector_property_map<int, boost::typed_identity_property_map<unsigned long> > > {lvalue}, graph_tool::PythonVertex)
This is not really a C++ thing, you are trying to access a vertex
property map with a tuple, instead of a vertex object. This tuple is
probably your list of targets. You need only to update line 1259 in
topology/__init__.py and exclude the case when 'target' is an
iterable. For instance:

    if source is not None and target != -1:
        try:
            dist_map = [dist_map[t] for t in target]
        except TypeError:
            dist_map = dist_map[target]

It seems you are almost there!

Best,
Tiago


--
Tiago de Paula Peixoto <[hidden email]>


_______________________________________________
graph-tool mailing list
[hidden email]
http://lists.skewed.de/mailman/listinfo/graph-tool

signature.asc (836 bytes) Download Attachment
--
Tiago de Paula Peixoto <[hidden email]>



If you reply to this email, your message will be added to the discussion below:
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/Mutliple-destination-Shortest-Path-Dijkstra-tp4026059p4026100.html
To start a new topic under Main discussion list for the graph-tool project, email [hidden email]
To unsubscribe from Main discussion list for the graph-tool project, click here.
NAML



--
François Kawala


View this message in context: Re: Mutliple destination Shortest Path Dijkstra
Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.