igraph-help
[Top][All Lists]

## Re: [igraph] clustering coefficient in bipartite network

 From: Gábor Csárdi Subject: Re: [igraph] clustering coefficient in bipartite network Date: Fri, 26 Nov 2010 11:34:07 +0100

```Hi Simone,

On Thu, Nov 25, 2010 at 5:22 PM, Simone Gabbriellini
> Hello List,
>
> I am trying to reproduce the clustering measures detailed in Latapy et al.
> Social Networks, 30 (2008).
>
> I attempted successfully to reproduce the ccN(G) clustering, which is
> basically an extension for bipartite networks of the global transitivity
> measure.
>
> I am stuck with the cc. measure of clustering coefficient, an extension of
> local transitivity for bipartite network - a reprise of what Borgatti and
> Everett have already suggested in 1997.
>
> I have to find, for each distance-2 neighbors of a node (which are still
> nodes of the same set), how many nodes of the other set they have in common.
>
> This is not all of what is needed to implement this measure, but it would be
> a great step for me...
>
> In order to find distance-2 neighbors for each node, I can use a partition,
> as Tamas suggested in a previous thread.
>
> V(g)[type==FALSE]\$neibi<-neighborhood(bipartite.projection(g)[[1]], 1)
>
> V(g)[type==TRUE]\$neibi<-neighborhood(bipartite.projection(g)[[2]], 1)

it is actually better to use vertex names to be sure that you assign
the second neighbors to the right vertices. While your solution works
if the order of the vertices is kept in the projections, this is not
documented for bipartite.projection, so you cannot take it for
granted.

Anyway, I think an easier way to get the second neighbors is to simply
subtract the 1-neighborhood from the 1-2-neighborhood, this works for
bipartite graphs.

nei12 <- neighborhood(g, 2)
nei1 <- neighborhood(g, 1)
nei2 <- mapply(setdiff, nei12, nei1)

> While in order to find neighbors in the bipartite, I can simply use:
>
> V(g)\$nei<-neighborhood(g, 1)
>
> now, how can I confront a node with every nodes listed in its neibi attribute
> in order to find if there are duplicates in each nei attributes? this is the
> hardest part I cannot solve.

If you have two numeric or character vectors, 'v1' and 'v2', then
'intersection(v1, v2)' treats them as sets and gives a vector that is
their intersection. Is this what you need?

G.

> any help more than welcome!
>
> Simone
> _______________________________________________
> igraph-help mailing list
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>

--