简体   繁体   English

使用R中的igraph计算两个节点之间的公共节点

[英]Counting common nodes between two nodes with igraph in R

Suppose I've generated an undirected graph(you can think about the graph of my friends on facebook).假设我已经生成了一个无向图(你可以想想我在 facebook 上的朋友的图)。 I would like to know, for each couple of nodes(taken two friends), the number of common "nodes" they have(the "mutual friends" of them).我想知道,对于每对节点(两个朋友),他们拥有的共同“节点”(他们的“共同朋友”)的数量。 Is there a function in igraph that I can use? igraph 中有我可以使用的函数吗?

Or in network or sna packages?或者在网络或 sna 包中?

Thank you.谢谢你。

If v_1 and v_2 are the two nodes in the graph g, then:如果 v_1 和 v_2 是图 g 中的两个节点,则:

cocitation(g, v_1)[v_2]

will give you the number of "mutual friends" they have.会给你他们拥有的“共同朋友”的数量。 Obviously is the same of显然是相同的

cocitation(g, v_2)[v_1]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM