You are on page 1of 2

Practical-7

AIM: Implement page rank algorithm.


CODE:
> library(igraph)

Attaching package: ‘igraph’

The following objects are masked from ‘package:stats’:

decompose, spectrum

The following object is masked from ‘package:base’:

union
>
A=matrix(c(0,1/2,1/2,0,0,0,1/6,1/6,1/6,1/6,1/6,1/6,1/3,1/3,0,0,1/3,0,0,0,0,0,1/2,1/2,0,0,0,1
/2,0,1/2,0,0,0,1,0,0),nrow=6)
> graph_A=graph.adjacency(A,weighted=TRUE,mode="directed")
> plot(graph_A)
> myresult<-page.rank(graph_A)$vector
> myresult
[1] 0.29387862 0.22199230 0.27377552 0.07753103 0.06828171 0.06454082
> myresult<-page.rank(graph_A)
> myresult
$vector
[1] 0.29387862 0.22199230 0.27377552 0.07753103 0.06828171 0.06454082

$value
[1] 1
$options
NULL

>

You might also like