graphtools
PageRank¶
Tools for computing PageRank of a graph.
approxpagerank
¶
approxpagerank(objs, func)
approximates the PageRank of nodes objs
in an undirected graph, where the weight of each edge is computed by function func
.
Info
According to Wikipedia, the PageRank of an undirected graph is statistically close to its degree distribution.
Tip
If there is no edge between two nodes, func
can simply return a weight of .
approxpagerank( [ "apple", "apple pie", "banana", "cherry pie" ], lambda a, b: settools.jaccard(set(a.split()), set(b.split())) ) # [0.5, # 0.8333333333333333, # 0, # 0.3333333333333333]