igraph-help
[Top][All Lists]

Re: [igraph] Confusing results with get_shortest_paths

 From: Tamás Nepusz Subject: Re: [igraph] Confusing results with get_shortest_paths Date: Wed, 17 Jul 2013 00:31:35 +0200

```Hello,

Your code seems to be fine but I cannot reproduce the issue on my machine --
neither with Python 2.7 nor with Python 3.3.1. Can you send me a self-contained
example that constructs the graph from scratch and reproduces the problem on
platform as possible (i.e. operating system, whether this is a 32-bit or 64-bit
machine, whether you have compiled igraph yourself or used an official
pre-compiled package, and anything else that you may deem relevant).

The output from my igraph session is as follows:

>>> import igraph
>>> g=igraph.Graph([(0,1),(1,2),(2,3)], directed=False)
>>> from itertools import combinations
>>> for s,t in combinations(g.vs, 2):
...     g.get_shortest_paths(s,t)[0]
...
[0, 1]
[0, 1, 2]
[0, 1, 2, 3]
[1, 2]
[1, 2, 3]
[2, 3]

All the best,
Tamas

On 16 Jul 2013, at 21:44, Frederik Elwert <address@hidden> wrote:

> Hello,
>
> I am new to igraph, so I might be getting something wrong. I am using
> igraph 0.6.5 with python3.
>
> I have a graph and want to calculate the shortest paths between all
> pairs of nodes:
>
>>>> graph.is_directed()
>        False
>>>> graph.get_edgelist()
>        [(0, 1), (1, 2), (2, 3)]
>>>> for source, target in combinations(graph.vs, 2):
>        ...     graph.get_shortest_paths(source, target)[0]
>        [0, 1]
>        [0, 1, 2]
>        [0, 2, 3]
>        [1, 2]
>        [1, 0, 3]
>        [2, 3]
>
> What bothers me: The paths [0, 2, 3] and [1, 0, 3] seem to be invalid.
> There should be no edge 0 -- 2 or 0 -- 3.
>
> Any hints?
>
> Regards,
> Frederik
>
>
> _______________________________________________
> igraph-help mailing list