igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] shortest path between two vertices


From: Chris Wj
Subject: Re: [igraph] shortest path between two vertices
Date: Mon, 2 Feb 2009 21:53:32 -0500

Hmm, I'm using development main branch 0.6 and this worked for me:
print g.shortest_paths( source=[0], target=[1], weights=None, mode=igraph.ALL) 

The docs from 0.5.1 (http://cneurocvs.rmki.kfki.hu/igraph/doc/python/index.html) say:

shortest_paths_dijkstra(vertices, weights=None, mode=OUT) 
Calculates shortest path lengths for given nodes in a graph.
Parameters:
vertices - a list containing the vertex IDs which should be included in the result.
weights - a list containing the edge weights. It can also be an attribute name (edge weights are retrieved from the given attribute) or None (all edges have equal weight). Edge weights must be non-negative for the algorithm to work (since weighted shortest path calculation is based on Dijkstra's algorithm)
mode - the type of shortest paths to be used for the calculation in directed graphs. OUT means only outgoing, IN means only incoming paths. ALL means to consider the directed graph as an undirected one.

Returns:the shortest path lengths for given nodes in a matrix



On Mon, Feb 2, 2009 at 9:33 PM, Rajarshi Guha <address@hidden> wrote:


On Mon, Feb 2, 2009 at 9:01 PM, Chris Wj <address@hidden> wrote:
From source doc:

 shortest_paths(source=None, target=None, weights=None, mode=OUT)
   
 

import igraph
G = igraph.Graph()
# create your graph
spaths_from_0 = G.shortest_paths(0)

Thanks for the pointer. But igraph 0.5.1 and Python 2.5 the following code gives an error

print g.shortest_paths( source=[0], targets=[1], weights=None, mode=igraph.ALL) 

Traceback (most recent call last):
  File "goanal.py", line 61, in <module>
    print g.shortest_paths( source=[0], targets=[1])
TypeError: 'source' is an invalid keyword argument for this function




--
Rajarshi Guha

_______________________________________________
igraph-help mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/igraph-help



reply via email to

[Prev in Thread] Current Thread [Next in Thread]