#!/usr/bin/perl

$damp = 0.85;
$a = $b = $c = 0;
$iterate = 40; # loop 40 times

# Plain Heirarchical
# forward links
# a -> b           - 1 outgoing link      - home
# b -> c1...c1000  - 1000 outgoing links  - link list
# c1,c1000 -> a    - 1 outgoing link      - spam pages

# i.e. "backward" links (what's pointing to me?)
# a <= 1000 * c
# b <= a
# c <= b/1000
while ($iterate--) {
	printf("a: %.5f b: %.5f c: %.5f\n", $a, $b, $c);

	$a = 1 - $damp + $damp * (1000 * $c);
	$b = 1 - $damp + $damp * ($a);
	$c = 1 - $damp + $damp * ($b/1000);
}
printf("Average pagerank = %.4f\n", ($a + $b + $c*1000) / 1002);

Outputs

a: 0.00000 b: 0.00000 c: 0.00000
a: 0.15000 b: 0.27750 c: 0.15024
a: 127.85049 b: 108.82292 c: 0.24250
a: 206.27456 b: 175.48338 c: 0.29916
a: 254.43674 b: 216.42123 c: 0.33396
a: 284.01434 b: 241.56219 c: 0.35533
a: 302.17868 b: 257.00188 c: 0.36845
a: 313.33386 b: 266.48378 c: 0.37651
a: 320.18453 b: 272.30685 c: 0.38146
a: 324.39170 b: 275.88294 c: 0.38450
a: 326.97543 b: 278.07911 c: 0.38637
a: 328.56216 b: 279.42784 c: 0.38751
a: 329.53661 b: 280.25612 c: 0.38822
a: 330.13505 b: 280.76479 c: 0.38865
a: 330.50256 b: 281.07718 c: 0.38892
a: 330.72826 b: 281.26902 c: 0.38908
a: 330.86687 b: 281.38684 c: 0.38918
a: 330.95199 b: 281.45919 c: 0.38924
a: 331.00427 b: 281.50363 c: 0.38928
a: 331.03637 b: 281.53091 c: 0.38930
a: 331.05609 b: 281.54767 c: 0.38932
a: 331.06819 b: 281.55796 c: 0.38932
a: 331.07563 b: 281.56428 c: 0.38933
a: 331.08020 b: 281.56817 c: 0.38933
a: 331.08300 b: 281.57055 c: 0.38933
a: 331.08472 b: 281.57201 c: 0.38934
a: 331.08578 b: 281.57291 c: 0.38934
a: 331.08643 b: 281.57347 c: 0.38934
a: 331.08683 b: 281.57380 c: 0.38934
a: 331.08707 b: 281.57401 c: 0.38934
a: 331.08722 b: 281.57414 c: 0.38934
a: 331.08732 b: 281.57422 c: 0.38934
a: 331.08737 b: 281.57427 c: 0.38934
a: 331.08741 b: 281.57430 c: 0.38934
a: 331.08743 b: 281.57432 c: 0.38934
a: 331.08744 b: 281.57433 c: 0.38934
a: 331.08745 b: 281.57433 c: 0.38934
a: 331.08746 b: 281.57434 c: 0.38934
a: 331.08746 b: 281.57434 c: 0.38934
a: 331.08746 b: 281.57434 c: 0.38934
Average pagerank = 1.0000

This page and its contents are copyright © 2024, Ian Rogers. Theme derived from Prav