Commit 197fa68c authored by Tiago Peixoto's avatar Tiago Peixoto

Properly norm pagerank() values

This makes the calculation coherent with the definition given in the
documentation.
parent 4dedb7f8
......@@ -35,6 +35,7 @@ struct get_pagerank
size_t& iter) const
{
typedef typename property_traits<RankMap>::value_type rank_type;
size_t NV = HardNumVertices()(g);
RankMap r_temp(vertex_index,num_vertices(g));
......@@ -47,10 +48,10 @@ struct get_pagerank
typename graph_traits<Graph>::vertex_descriptor v = vertex(i, g);
if (v == graph_traits<Graph>::null_vertex())
continue;
rank[v] = 1.0/N;
rank[v] = 1.0 / NV;
}
rank_type delta = 2*epslon;
rank_type delta = epslon + 1;
rank_type d = damping;
iter = 0;
while (delta >= epslon)
......@@ -75,7 +76,7 @@ struct get_pagerank
source(*e, g);
r += get(rank, s) / out_degree(s, g);
}
put(r_temp, v, (1.0 - d) + d * r);
put(r_temp, v, (1.0 - d) / NV + d * r);
delta += abs(get(r_temp, v) - get(rank,v));
}
......
......@@ -109,23 +109,23 @@ def pagerank(g, damping=0.8, prop=None, epsilon=1e-6, max_iter=None,
>>> g = gt.random_graph(100, lambda: (poisson(3), poisson(3)))
>>> pr = gt.pagerank(g)
>>> print pr.a
[ 0.87011681 1.73449398 0.47587866 0.4534494 0.2 1.26596887
0.60964865 0.68064477 0.8137542 0.86269096 0.51833002 0.49194604
0.74875795 0.52831993 0.601438 0.63921165 1.32489495 0.68360746
1.02608206 0.90903761 1.1026286 0.56290713 0.2 0.30840086
0.90726785 0.35583967 0.95582862 0.232 0.41090313 0.88734742
0.47424296 0.66138242 1.26313184 0.7459428 0.84110051 0.9497316
1.0589998 0.94412292 0.26433617 0.86197354 0.2 0.25333333
0.65974242 0.69889305 1.02798531 0.77618244 0.57905885 1.12828577
0.232 1.18366748 0.38929224 1.72424164 0.47966878 1.0931673
0.45937603 1.09479766 0.80274459 0.44782081 1.04618114 0.25333333
0.82295953 0.40210109 0.72779393 0.75075946 0.41742276 0.2
0.8984279 0.92941713 0.69682427 0.69340983 1.02679348 0.2
0.67750539 0.85622403 0.77232588 1.09093307 1.14410169 0.59413937
0.54456339 0.64371752 0.40275133 0.72976606 1.40446885 0.2
0.31831299 0.3734494 0.2562224 1.05807688 1.02419007 0.82747632
0.49646186 0.72960178 0.48621114 1.42147072 0.65622314 0.31664379
1.55387576 0.58439879 2.03922765 1.47802266]
[ 0.0087012 0.01734503 0.0047588 0.00453451 0.002 0.01265973
0.0060965 0.00680647 0.00813758 0.00862694 0.00518331 0.00491948
0.00748761 0.00528322 0.00601439 0.00639214 0.013249 0.0068361
0.01026087 0.00909041 0.01102634 0.0056291 0.002 0.00308401
0.00907272 0.0035584 0.00955833 0.00232 0.00410904 0.00887352
0.00474244 0.00661384 0.01263138 0.00745946 0.00841104 0.00949735
0.01059004 0.00944125 0.00264336 0.00861976 0.002 0.00253333
0.00659745 0.00698895 0.01027991 0.00776186 0.00579061 0.01128291
0.00232 0.01183673 0.00389293 0.01724249 0.0047967 0.01093172
0.00459377 0.01094803 0.00802747 0.00447822 0.01046185 0.00253333
0.00822962 0.00402102 0.00727797 0.00750763 0.00417424 0.002
0.00898431 0.00929422 0.00696827 0.00693413 0.01026798 0.002
0.00677507 0.00856227 0.00772329 0.01090938 0.01144107 0.00594142
0.00544564 0.0064372 0.00402752 0.00729768 0.01404475 0.002
0.00318314 0.00373451 0.00256223 0.01058081 0.01024193 0.0082748
0.00496463 0.00729605 0.00486213 0.01421478 0.00656225 0.00316644
0.01553884 0.005844 0.02039237 0.01478031]
References
----------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment