[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] igraph-help Digest, Vol 79, Issue 12
From: |
Tamás Nepusz |
Subject: |
Re: [igraph] igraph-help Digest, Vol 79, Issue 12 |
Date: |
Wed, 26 Feb 2014 16:16:09 +0100 |
> I am finding it challenging to count the number of triangles between two
> nodes say u and v for all u,v in N using R
If you mean the number of triangles that contain both u and v, for every u and
v in the network, then you can use the cocitation function (igraph_cocitation
in C, cocitation() in R, Graph.cocitation() in Python. This is because the
number of triangles that involve both u and v is equal to the number of common
neighbors of u and v, which is exactly what cocitation() calculates for an
undirected graph. Note that cocitation() gives you a full matrix, i.e. you’ll
get an n x n matrix for n vertices, so you cannot use it directly if your graph
is large. In this case, you’ll have to iterate over the (u,v) pairs of interest
on your own, fetch the neighbors, and then calculate the intersection.
T.