According to this post, weights of a weighted digraph have an effect on the Page Rank of the graph. I have tried the code in that post:
from networkx.algorithms.link_analysis.pagerank_alg import pagerank_numpy
ddd=nx.DiGraph()
ddd.add_weighted_edges_from([('A','B',0.5),('A','C',0.5)])
print(pagerank_numpy(ddd))
ddd['A']['C']['weight']=1
print(pagerank_numpy(ddd))
>>> {'A': 0.2597402597402597, 'B': 0.37012987012987014, 'C': 0.37012987012987014}
>>> {'A': 0.2597402597402599, 'B': 0.3333333333333334, 'C': 0.40692640692640686}
However, at the same time, pagerank_numpy
has a parameter called weight
. According to the documentation:
weight (key, optional) – Edge data key to use as weight. If None weights are set to 1.
In the above example, weight
is not set, but it does not seem that weights are all set to 1. So, what does this parameter weight
really do?
Version of NetworkX: 2.1
The PageRank algorithm assigns weights to nodes according to a random walk on a network. We can modify the algorithm by biasing the walk to follow some edges more than others. To do this we weight the network's edges. Networkx is very flexible about edge weights. We can have weights whose name is 'weight'
or 'scale_factor'
or 'relative_frequency'
or any string we want to name them by. So the PageRank algorithm needs to know which name to use.
That is what you are telling the algorithm when you pass it the weight
parameter. If it doesn't get that, it treats all edges as having weight 1.