Thank you!

It's nice to know that the function "get_shortest_paths" support weights.
So, the formula should be something like the following:

   av_path_length = mean([pl for pl in
sum(g.shortest_paths(weights=g.vs['weight']), []) if pl > 0 and pl !=
float('inf')])

I have update the gist, in case anybody is interested:
https://gist.github.com/4124710

Thank you again, I have been a bit stuck on this in the last few days :-)





On Wed, Nov 21, 2012 at 2:13 PM, Tamás Nepusz <[email protected]> wrote:

> > Hi, I solved this by myself..
> Great! :) Now, if you want to generalize it to weighted graphs, there are
> at least two possible ways: either you calculate the average weight of the
> shortest paths or you still calculate the average path length but take the
> weights into account when you calculate what the shortest path is. Both are
> relatively easy to implement if you use the output of get_shortest_paths()
> or shortest_paths() since they both support weights.
>
> Best,
> Tamas
>
>


-- 
Giovanni Dall'Olio, phd student
IBE, Institut de Biologia Evolutiva, CEXS-UPF (Barcelona, Spain)

My blog on bioinformatics: http://bioinfoblog.it
_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to