igraph: enumerating triads in a graph and calculating common neighbors for dyads

时间:2015-05-24 20:54:27

标签: python r igraph

I'm working with igraph on an undirected graph on two tasks. My graph has about 220 million edges.

Tasks 1:

I want to get a list of triads in the graph, and there are only two specific types of triads I would want.

1) triangle: A-B-C & A-C I guess that can be pretty easily done with "cliques(g, min = 3, max = 3)"

2) A-B-C (A and C not connected) I'm not sure how this is done, and I want to make sure that in the list B is clearly identified as the broker.

Task 2

Once I have the list of triads, I would want to calculate, from the original graph, the number of shared links (or common neighbors) between each pair of node in these triads.

For example: in the following data frame, we have a triangle triad ABC, A and B share 2 common links (C and E); B and C share 1 common link (E), A and C share 1 common link (B)

f1 f2
A C
B A
C B
D B
E A
B E

Can it only be done by intersect() all the nodes got from neighborhood()? Is there are more efficient way?

Many thanks!!

0 个答案:

没有答案