加权边缘如何影响networkx中的PageRank? [英] How do weighted edges affect PageRank in networkx?

查看:753
本文介绍了加权边缘如何影响networkx中的PageRank?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在玩networkx(python中的图形库),发现文档说PageRank算法在评分时考虑了边缘权重,但是我想知道更大的边缘权重是更好还是更低的权重呢?

I'm playing around with networkx (graph library in python) and I found documentation saying the PageRank algorithm takes edge weights into account when scoring, but I was wondering if larger edge weights were better or lower weights better?

推荐答案

不久,对于进入的节点,权重较大.

Shortly, large weights are better for incoming nodes.

PageRank在有向加权图上工作.如果页面A链接到页面B,则页面B的得分会上升,即页面B(节点)的输入越多,其得分就越高.

PageRank works on a directed weighted graph. If page A has a link to page B, then the score for B goes up, i.e. the more input the page B (node) have, the higher is its score.

PageRank上的维基百科文章以获取更多详细信息.

Wikipedia article on PageRank for further details.

编辑:让我们做个实验.创建一个具有3个节点和两个权重相等的有向边的有向图.

Edit: let's make an experiment. Create a directed graph with 3 nodes and two directed edges with equal weights.

import networkx as nx
D=nx.DiGraph()
D.add_weighted_edges_from([('A','B',0.5),('A','C',0.5)])
print nx.pagerank(D)

>> {'A': 0.259740259292235, 'C': 0.3701298703538825, 'B': 0.3701298703538825}

现在,增加(A,C)边缘的权重:

Now, increase the weight of the (A,C) edge:

D['A']['C']['weight']=1
print nx.pagerank(D)    

>> {'A': 0.259740259292235, 'C': 0.40692640737443164, 'B': 0.3333333333333333}

如您所见,随着传入边缘权重的增加,节点C得分更高.

As you see, the node C got higher score with increasing weight of the incoming edge.

这篇关于加权边缘如何影响networkx中的PageRank?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆