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:01:09 -0500

From source doc:

 shortest_paths(source=None, target=None, weights=None, mode=OUT)
   
    Calculates shortest path lengths for given nodes in a graph.
   
    @param source: a list containing the source vertex IDs which should be
      included in the result. If C{None}, all vertices will be considered.
    @param target: a list containing the target vertex IDs which should be
      included in the result. If C{None}, all vertices will be considered.
    @param weights: a list containing the edge weights. It can also be
      an attribute name (edge weights are retrieved from the given
      attribute) or C{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)
    @param mode: the type of shortest paths to be used for the
      calculation in directed graphs. L{OUT} means only outgoing,
      L{IN} means only incoming paths. L{ALL} means to consider
      the directed graph as an undirected one.
    @return: the shortest path lengths for given nodes in a matrix

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

-Chris

On Mon, Feb 2, 2009 at 6:16 PM, Rajarshi Guha <address@hidden> wrote:
Hi, I'm using the Python igraph API and am trying to get the shortest path between two vertices. In general I will have multiple end vertices and a single start vertex. However I can't seem to find anything in Python API that lets me do this. I do see in the Ruby API that there is afunction that lets me do this:

http://igraph.rubyforge.org/igraph/classes/IGraph/ShortestPaths.src/M000108.html

Could somebody point me to the equivalent Python method.

Thanks,
--
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]