Example Source Code

PageRank Explained Example 12

#!/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;

# Plain; Heirarchical;
# forward; links;
# a; -;> b;     -; 1; outgoing; link;  -; home;
# b; -;> a;,c   -; 2; outgoing; links; -; doc; page; 1;
# c; -;> b;,a,d -; 3; outgoing; links; -; doc; page; 2;
# d; -;> a;,c   -; 2; outgoing; links; -; doc; page; 3;

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

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

Run this program

Back to PageRank Explained Example 12

 

IPRcom Service

Search Engine Optimisation (SEO)

MailLocate

Ever changed your email address? Never lose a contact again! Permanently lose spam and junk emailers!
Free sign-up

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