ra_index_soundarajan_hopcroft#
- ra_index_soundarajan_hopcroft(G, ebunch=None, community='community')[源代码]#
使用社区信息计算ebunch中所有节点对的资源分配索引。
对于两个节点 \(u\) 和 \(v\) ,此函数计算资源分配指数时只考虑属于相同社区的公共邻居 \(u\) 和 \(v\) 。从数学上讲,
\[\和w \ in \ gamma(u \ cap \ gamma(v)\ frac f(w)\ gamma(w)\]哪里 \(f(w)\) 等于1,如果 \(w\) 属于同一个社区,与 \(u\) 和 \(v\) 否则为0,否则为 \(\Gamma(u)\) 的邻居集。 \(u\) 。
- 参数
- G图表
网络X无向图。
- ebunch节点对的可迭代,可选(默认=无)
将为迭代表中给出的每对节点计算分数。这些对必须以2元组(u,v)的形式给出,其中u和v是图中的节点。如果eBunch为None,则将使用图形中所有不存在的边。默认值:无。
- community字符串,可选(默认为‘社区’)
包含社区信息的节点属性名称。G [u] [社区] 标识您属于哪个社区。每个节点最多属于一个社区。缺省值:‘社区’。
- 返回
- piter迭代器
形式为(u,v,p)的3元组的迭代器,其中(u,v)是一对节点,p是它们的分数。
工具书类
- 1
Sucheta Soundarajan和John Hopcroft。利用社区信息提高链路预测方法的精度。在《第21届国际会议论文集:万维网伙伴》(www'12 companion)。ACM,纽约,纽约,美国,607-608。http://doi.acm.org/10.1145/2187980.2188150
实例
>>> G = nx.Graph() >>> G.add_edges_from([(0, 1), (0, 2), (1, 3), (2, 3)]) >>> G.nodes[0]["community"] = 0 >>> G.nodes[1]["community"] = 0 >>> G.nodes[2]["community"] = 1 >>> G.nodes[3]["community"] = 0 >>> preds = nx.ra_index_soundarajan_hopcroft(G, [(0, 3)]) >>> for u, v, p in preds: ... print(f"({u}, {v}) -> {p:.8f}") (0, 3) -> 0.50000000