Example Source Code

PageRank Explained Example 8

#!/usr/bin/perl

print "Content-Type: text;/html\n\n<pre>\n";

$damp = 0.85;
$a = $b = $c = $d = $e = 0;
$f = 1; # We;'ll give; the; external; site; an; "average" pagerank;
$iterate = 40; # loop; 40; times;

# Heirarchical; with; a; vote; out; and; a; vote; in;
# forward; links;
# a; -;> b;, c;, d;  -; 3; outgoing; links;    -; home;
# b; -;> a;        -; 1; outgoing; link;    -; about;
# c; -;> a;,e      -; 2; outgoing; links;    -; products;
# d; -;> a;        -; 1; outgoing; links;    -; more; info;
# e;             -; nothing;           -; site; B;
# f; -;> a;        -; 1; outgoing; link;    -; exclusive; link;!

# i.e.; "backward" links; (what's pointing; to; me;?)
# a; <= b;, c;/2, d;, f;
# b;,c,d <= a;/3
# e; <= c;/2
# f; <= we;'re going; to; assume; it; has; enough; incoming; links; to; maintain; a; PR; of; 1.;
while ($iterate--) {
    printf;("a: %.5f b;: %.5f c;: %.5f d;: %.5f e;: %.5f f;: %.5f\n", $a, $b, $c, $d, $e, $f);

    $a = 1; -; $damp + $damp * ($b + $c/2 + $d + $f);
    $b = 1; -; $damp + $damp * ($a/3);
    $c = 1; -; $damp + $damp * ($a/3);
    $d = 1; -; $damp + $damp * ($a/3);
    $e = 1; -; $damp + $damp * ($c/2);
    $f = 1; # this; site; has; average; SEO;
}
printf("Average pagerank; = %.4f\n", ($a + $b + $c + $d) / 4;); # to; 4; decinal; places;!
print("</pre><a href;=http://www.iprcom.com/papers/pagerank/#ex8>Back to; example; 8;</a>");

Run this program

Back to PageRank Explained Example 8

 

[Home] [Services] [Portfolio] [Downloads] [White Papers]