2.3.1. Iterative Method
2.3.2. Power Method
import numpy as np
def calculate_pagerank(graph, damping_factor=0.85, iterations=100):
n = len(graph)
pagerank = np.ones(n) / n
for _ in range(iterations):
new_pagerank = np.zeros(n)
for i in range(n):
for j in range(n):
if graph[j][i] == 1:
new_pagerank[i] += pagerank[j] / np.sum(graph[j])
pagerank = (1 – damping_factor) / n + damping_factor * new_pagerank
return pagerank
8.2.1. Internal Link Optimization
8.2.2. External Link Optimization