#!/usr/bin/perl
print "Content-Type: text/html\n\n<pre>\n";
$damp = 0.85;
$a = $b = $c = $d = $e = $f = $g = $h = 0;
$iterate = 40; # loop 40 times
# Extensive Interlinking - "Fully Meshed"
# forward links
# a -> b,c,d - 3 outgoing links - home
# b -> c,d,a - 3 outgoing link - about
# c -> d,a,b - 3 outgoing link - products
# d -> a,b,c - 3 outgoing links - more info
# i.e. "backward" links (what's pointing to me?)
# a <= b/3,c/3,d/3
# b <= c/3,d/3,a/3
# c <= d/3,a/3,b/3
# d <= a/3,b/3,c/3
while ($iterate--) {
printf("a: %.5f b: %.5f c: %.5f d: %.5f\n", $a, $b, $c, $d);
$a = 1 - $damp + $damp * ($b/3 + $c/3 + $d/3);
$b = 1 - $damp + $damp * ($c/3 + $d/3 + $a/3);
$c = 1 - $damp + $damp * ($d/3 + $a/3 + $b/3);
$d = 1 - $damp + $damp * ($a/3 + $b/3 + $c/3);
}
printf("Average pagerank = %.4f\n", ($a + $b + $c + $d) / 4); # to 4 decimal places!
print("</pre><a href=http://www.ianrogers.net/google-page-rank/#ex7>Back to example 7</a>");
Design by Ian Rogers based on Connections 1.0
