Ejemplo de rango de página
#!/usr/bin/perl
$damp = 0.85;
$norm = 1 - $damp;
$a = 0;
$b = 0;
$c = 0;
$d = 0;
$i = 40; # loop 40 times
# forward links
# a -> b, c - 2 outgoing links
# b -> c - 1 outgoing link
# c -> a - 1 outgoing link
# d -> a - 1 outgoing link
# i.e. "backward" links (what's pointing to me?)
# a <= c
# b <= a
# c <= a, b, d
# d - nothing
while ($i--) {
printf(
"a: %.5f b: %.5f c: %.5f d: %.5f\n",
$a, $b, $c, $d
);
$a = $norm + $damp * $c;
$b = $norm + $damp * ($a/2);
$c = $norm + $damp * ($a/2 + $b + $d);
$d = $norm;
}
printf("Average pagerank = %.4f\n", ($a + $b + $c + $d) / 4);
Zany Zebra