[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] average shortest path between same sets of nodes
From: |
Simone Gabbriellini |
Subject: |
Re: [igraph] average shortest path between same sets of nodes |
Date: |
Thu, 20 Jan 2011 18:01:06 +0100 |
thanks Tamas,
I've tried it, but I get:
TypeError: 'source' is an invalid keyword argument for this function
apparently, in the docs the only argument for this function are:
shortest_paths(vertices, weights=None, mode=OUT)
best,
simone
2011/1/20 Tamas Nepusz <address@hidden>:
> Hi,
>
> To implement mean(), you have two choices:
>
> 1. Implement it yourself:
>
> def mean(xs):
> return sum(xs) / float(len(xs))
>
> 2. Implement it using igraph's RunningMean class (this one works with
> iterables as well, not just with sequences):
>
> def mean(iterable):
> rm = RunningMean()
> rm << iterable
> return rm.mean
>
> After that, you can simply do something like this:
>
> vs = [idx for idx, type in enumerate(g.vs["type"]) if type is False]
> mean(lcc.shortest_paths(source=vs, target=vs, mode="all")
>
> igraph 0.6 also supports the following, I can't remember whether 0.5.4
> also understands this or not, but it's worth a try:
>
> mean(lcc.shortest_paths(source=g.vs(type=False),
> target=g.vs(type=False), mode="all")
>
> --
> T.
>
> On 01/20/2011 05:04 PM, Simone Gabbriellini wrote:
>> Hello again,
>>
>> After retrieving the largest connected component (lcc) of a bipartite
>> graph, I would like to find the average shortest paths for top and
>> bottom nodes. Is there something like this in the python interface:
>>
>> mean(shortest.paths(lcc, v=V(lcc)[type==FALSE],
>> to=V(lcc)[type==FALSE], mode = 'all'))
>>
>> mean(shortest.paths(lcc, v=V(lcc)[type==TRUE], to=V(lcc)[type==TRUE],
>> mode = 'all'))
>>
>> best,
>> simone
>>
>> _______________________________________________
>> igraph-help mailing list
>> address@hidden
>> http://lists.nongnu.org/mailman/listinfo/igraph-help
>>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>