I have a networkx graph G, say for example
import networkx as nx
G=nx.erdos_renyi_graph(100,.1)
I would like to count in an efficient way to the number of open triples, that is, the frequency of the pattern: A is connected to B, B is connected to C but A and B are not connected.
Is there a clever way to exploit a built in function for this?
If you can compute the distance matrix (1 if i->j, else 0)
of G
, you can square it and for each non-diagonal entry, check if a[i,j]
is different from a[j,i]
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.