有没有一种有效的方法来计算python中共同邻居(CC)和优先附件(PA)的矩阵分数?我正在使用 igraph 计算其他方法的分数矩阵,例如 jaccard 系数 (Graph.similarity_jaccard())、dice (Graph.similarity_dice) 和 adam/adar (Graph.similarity_inverse_log_weighted()),但我没有找到任何函数计算 CC 和 PA 的得分矩阵。
目前我正在做:
#Preferential attachment score between nodes i and j in a graph g
len(g.neighbors(i))*len(g.neighbors(j))
#Common neighbors score between nodes i and j in a graph g
len(g.neighbors(i) and g.neighbors(j))
但我必须对网络中的所有边缘(i,j)执行此操作,在我的情况下它确实很大。
如果有人知道任何生成我正在寻找的分数矩阵的数学矩阵运算,我也会很感激。