⢠Compute the eigen-decomposition of B and verify that you indeed get an eigenvalueof 1 as the largest eigenvalue and that its corresponding eigenvector is the same vector that you obtained in the previous power iteration method. Further, this eigenvector has all positive entries and it sums to 1.
# Decomposing B
eigen_decomp <- eigen(B)
# Maximum eigen value we get is indeed 1
max_value<-which.max(eigen_decomp$values)
## Warning in which.max(eigen_decomp$values): imaginary parts discarded in
## coercion
# check this eigenvector has all positive entries and it sums to 1
eig_vec2 <- as.numeric((1/sum(eigen_decomp$vectors[,1]))*eigen_decomp$vectors[,1])
sum(eig_vec2)
## [1] 1
⢠Use the graph package in R and its page.rank method to compute the Page Rank of the graph as given in A.
library(igraph)
##
## Attaching package: 'igraph'
## The following objects are masked from 'package:stats':
##
## decompose, spectrum
## The following object is masked from 'package:base':
##
## union
graph_A <- graph.adjacency(t(A), weighted = TRUE, mode = "directed")
plot(graph_A)

eig_vec3 <- page.rank(graph_A)$vector
eig_vec3
## [1] 0.05170475 0.07367926 0.05741241 0.34870369 0.19990381 0.26859608