-
大小: 1KB文件類型: .py金幣: 2下載: 1 次發布日期: 2021-01-02
- 語言: Python
- 標簽: Python??LeaderRank??
資源簡介
基于Python2.7實現的LeaderRank復雜網絡節點排序算法,算法輸出排序后每個節點的重要性值 參考論文:2011-Leaders in Social Networks, the Delicious
代碼片段和文件信息
#?-*-?coding:?UTF-8?-*-
“““
Created?on?18-3-5
@summary:?LeaderRank?節點排序算法
@author:?dreamhomes
“““
from?src.LPA?import?get_graph
def?leaderrank(graph):
????“““
????節點排序
????:param?graph:復雜網絡圖Graph
????:return:?返回節點排序值
????“““
????#?節點個數
????num_nodes?=?graph.number_of_nodes()
????#?節點
????nodes?=?graph.nodes()
????#?在網絡中增加節點g并且與所有節點進行連接
????graph.add_node(0)
????for?node?in?nodes:
????????graph.add_edge(0?node)
????#?LR值初始化
????LR?=?dict.fromkeys(nodes?1.0)
????LR[0]?=?0.0
????#?迭代從而滿足停止條件
????while?True:
????????tempLR?=?{}
????????for?node1?in?graph.nodes():
????????????s?=?0.0
????????????for?node2?in?graph.nodes():
????????????????if?node2
評論
共有 條評論