Advertisement
cd62131

PageRank

Aug 10th, 2014
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.50 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use feature 'say';
  5. use Algorithm::PageRank::XS;
  6. my $page_rank = Algorithm::PageRank::XS->new();
  7. $page_rank->graph([
  8.       1 => 2
  9.     , 1 => 3
  10.     , 1 => 4
  11.     , 1 => 5
  12.     , 2 => 1
  13.     , 3 => 1
  14.     , 3 => 2
  15.     , 4 => 2
  16.     , 4 => 3
  17.     , 4 => 5
  18.     , 5 => 1
  19.     , 5 => 3
  20.     , 5 => 4
  21.     , 5 => 6
  22.     , 6 => 1
  23.     , 6 => 5
  24.     , 7 => 5
  25.   ]);
  26. my $r = $page_rank->result();
  27. foreach my $id (sort keys %$r) {
  28.   say "id: $id, rank: $r->{$id}";
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement