igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] clustering coefficients for bipartite networks


From: Simone Gabbriellini
Subject: Re: [igraph] clustering coefficients for bipartite networks
Date: Tue, 1 Feb 2011 17:40:28 +0100

I guess I have to refine this description: I need to find, for a node u, the 
average of clustering values that u has with all the neighbors v which u share 
some neighbors with, where the clustering value is computed as the number of 
same neighbors between u and v divided by the total number of unique neighbors 
of u and v.

is this something appreciable in that direction?

[ ( len( set( g.neighbors(u) ) & set( g.neighbors(v) ) ) / len( list( set( 
g.neighbors(u) + g.neighbors(v) ) ) ) ) for u in g.vs(type=0) for v in 
g.vs(type=0)]

best,
simone

Il giorno 01/feb/2011, alle ore 16.08, Simone Gabbriellini ha scritto:

> I am really facing difficulties in translating the code from R... Maybe, it 
> would be better to start from scratch in python.
> 
> I am trying to find, for every pair (u,v) of nodes of the same set, how many 
> neighbors of the other sets they have in common divided by the  sum of unique 
> neighbors of u and v. 
> 
> is there a simple way to accomplish this task?
> 
> If I am right, this should produce, for every node, a list of values as long 
> as the number of pairs of nodes in a set. I then can use a running mean to 
> calculate the average value of the list.
> 
> best,
> Simone
> 
> Il giorno 29/gen/2011, alle ore 11.50, Tamás Nepusz ha scritto:
> 
>>> I don't think I can define functions on the fly like in R (but maybe I am 
>>> wrong)
>> You can, see the lambda keyword:
>> 
>> http://diveintopython.org/power_of_introspection/lambda_functions.html
>> 
>> You can also define functions within functions, so if your auxiliary 
>> function is longer (but you won't use it from anywhere else), you can define 
>> it inside your original function.
>> 
>> I don't know exactly what the difference is between the different *apply 
>> functions in R (lapply, sapply, apply), but I believe that Python's map() 
>> function does something similar. But even better, use list comprehensions if 
>> possible:
>> 
>> http://docs.python.org/tutorial/datastructures.html#list-comprehensions
>> 
>> -- 
>> T.
>> 
>> 
>> _______________________________________________
>> 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]