This project implements the PageRank algorithm using the Power Method and applies it to a hyperlink graph obtained from the Indian Tourism website.
The main objectives of this project are:
- Model a collection of webpages as a directed graph.
- Construct the Google transition matrix.
- Handle webpages with no outgoing links (dangling nodes).
- Compute the PageRank vector using the Power Method.
- Rank webpages according to their PageRank scores.
- Study the effect of the damping parameter
$p$ . - Visualize the PageRank distribution across webpages.
The dataset used in this project is:
IndianTourism.mat
The dataset contains information about approximately 500 webpages and their corresponding hyperlink graph.
The MATLAB file contains the following variables:
| Variable | Description |
|---|---|
U |
List of webpage URLs |
G |
Connectivity matrix representing hyperlinks between webpages |
The connectivity matrix
Therefore, the
The web graph contains:
webpages and
non-zero entries, corresponding to the hyperlinks in the graph.
Let
The out-degree of webpage
Let
The Google transition matrix
where:
-
$p$ is the damping/follow-link probability. -
$1-p$ is the random-jump probability. -
$n$ is the total number of webpages. -
$c_j$ is the out-degree of webpage$j$ .
A webpage with no outgoing hyperlinks is called a dangling node or dead-end page.
For such a webpage,
The corresponding column of
This ensures that the transition matrix remains a valid stochastic matrix.
The PageRank vector
It satisfies
Equivalently,
The PageRank vector is normalized such that
Therefore,
Each entry
The PageRank vector is computed using the Power Method.
The initial vector is chosen as a uniform probability distribution:
At each iteration, the PageRank vector is updated according to
The resulting vector is normalized using the
The iterations continue until
In this implementation:
and the maximum number of iterations is
PageRank(U, G, p=0.85, max_iter=1000, tol=1e-10)| Parameter | Description | Default |
|---|---|---|
U |
List of webpage URLs | — |
G |
Webpage connectivity matrix | — |
p |
Probability of following a hyperlink | 0.85 |
max_iter |
Maximum number of Power Method iterations | 1000 |
tol |
Convergence tolerance | 1e-10 |
The overall PageRank computation follows these steps:
- Load the webpage URLs
$U$ and connectivity matrix$G$ . - Compute the out-degree of every webpage.
- Identify dangling webpages with zero out-degree.
- Construct the Google matrix
$A$ . - Initialize the PageRank vector uniformly.
- Apply the Power Method.
- Normalize the PageRank vector.
- Check the convergence criterion.
- Sort webpages according to their PageRank scores.
- Display the top-ranked webpages.
- Repeat the experiment for different values of
$p$ .
Load U and G
|
v
Compute out-degree
|
v
Find dangling nodes
|
v
Construct Google Matrix A
|
v
Initialize x = 1/n
|
v
x_new = A @ x
|
v
Normalize
|
v
Check convergence
/ \
No Yes
| |
v v
Repeat iteration Return x
The PageRank algorithm was evaluated for the following values of the damping parameter:
The value
For each value of
- Constructs the Google matrix.
- Computes the PageRank vector.
- Generates a bar plot of PageRank values.
- Identifies the top 10 webpages.
- Prints the corresponding URLs and PageRank scores.
| Rank | URL | PageRank |
|---|---|---|
| 1 | http://www.makeinindia.com |
0.017018 |
| 2 | http://www.nic.in |
0.014354 |
| 3 | http://india.gov.in |
0.011159 |
| 4 | http://subscribe.businessworld.in |
0.009505 |
| 5 | http://analytics.wrc.nic.in/cmfanalytics |
0.008160 |
| 6 | http://cmf.gov.in |
0.008131 |
| 7 | http://drupal.org |
0.006877 |
| 8 | http://foodprocessingindia.gov.in |
0.006595 |
| 9 | http://pgportal.gov.in |
0.006276 |
| 10 | http://nkn.gov.in/en |
0.006211 |
Observation: For http://www.makeinindia.com with a PageRank of 0.017018.
| Rank | URL | PageRank |
|---|---|---|
| 1 | http://www.makeinindia.com |
0.032895 |
| 2 | http://subscribe.businessworld.in |
0.018384 |
| 3 | http://www.nic.in |
0.017158 |
| 4 | http://analytics.wrc.nic.in/cmfanalytics |
0.013249 |
| 5 | http://india.gov.in |
0.013014 |
| 6 | http://foodprocessingindia.gov.in |
0.010858 |
| 7 | http://cmf.gov.in |
0.008713 |
| 8 | http://recruitment.nic.in |
0.008433 |
| 9 | http://nkn.gov.in/en |
0.008433 |
| 10 | http://drupal.org |
0.007537 |
Observation: As makeinindia.com increases from 0.017018 to 0.032895, indicating that the webpage receives significant importance from the connectivity structure of the graph.
The assignment specifies
| Rank | URL | PageRank |
|---|---|---|
| 1 | http://www.makeinindia.com |
0.057644 |
| 2 | http://subscribe.businessworld.in |
0.035303 |
| 3 | http://analytics.wrc.nic.in/cmfanalytics |
0.020900 |
| 4 | http://www.nic.in |
0.018004 |
| 5 | http://foodprocessingindia.gov.in |
0.017526 |
| 6 | http://india.gov.in |
0.013467 |
| 7 | http://nkn.gov.in/en |
0.009677 |
| 8 | http://recruitment.nic.in |
0.009677 |
| 9 | http://cmf.gov.in |
0.008479 |
| 10 | http://drupal.org |
0.007448 |
Observation: The highest-ranked webpage is http://www.makeinindia.com with a PageRank score of 0.057644, followed by http://subscribe.businessworld.in at 0.035303. A relatively small group of webpages receives a significant fraction of the PageRank mass due to the structure of the hyperlink graph.
| Rank | URL | PageRank |
|---|---|---|
| 1 | http://www.makeinindia.com |
0.140801 |
| 2 | http://subscribe.businessworld.in |
0.108806 |
| 3 | http://analytics.wrc.nic.in/cmfanalytics |
0.046288 |
| 4 | http://foodprocessingindia.gov.in |
0.040204 |
| 5 | http://www.nic.in |
0.014710 |
| 6 | http://india.gov.in |
0.010870 |
| 7 | http://nkn.gov.in/en |
0.008647 |
| 8 | http://recruitment.nic.in |
0.008647 |
| 9 | http://bwdisrupt.businessworld.in |
0.006942 |
| 10 | http://www.digitalmarket.asia |
0.006485 |
Observation: For makeinindia.com rises to 0.140801 and subscribe.businessworld.in to 0.108806 — the distribution becomes substantially more concentrated as
| Rank | URL | PageRank |
|---|---|---|
| 1 | http://www.makeinindia.com |
0.391034 |
| 2 | http://subscribe.businessworld.in |
0.377298 |
| 3 | http://analytics.wrc.nic.in/cmfanalytics |
0.122678 |
| 4 | http://foodprocessingindia.gov.in |
0.108991 |
| 5 | http://www.nic.in |
0.000000 |
| 6 | http://india.gov.in |
0.000000 |
| 7 | http://bwdisrupt.businessworld.in |
0.000000 |
| 8 | http://www.digitalmarket.asia |
0.000000 |
| 9 | http://www.bwcio.com |
0.000000 |
| 10 | http://nkn.gov.in/en |
0.000000 |
Observation: With
| Webpage | PageRank |
|---|---|
http://www.makeinindia.com |
0.391034 |
http://subscribe.businessworld.in |
0.377298 |
http://analytics.wrc.nic.in/cmfanalytics |
0.122678 |
http://foodprocessingindia.gov.in |
0.108991 |
Their combined PageRank is approximately
so almost the entire PageRank probability mass is concentrated in these four webpages, and several others receive a PageRank of zero.
| Damping Factor |
PageRank of makeinindia.com
|
|---|---|
| 0.60 | 0.017018 |
| 0.75 | 0.032895 |
| 0.85 | 0.057644 |
| 0.95 | 0.140801 |
| 1.00 | 0.391034 |
The results show a clear increase in PageRank concentration as
The damping parameter controls the balance between following hyperlinks (probability
| Link Following | Random Jumping | Effect | |
|---|---|---|---|
| 0.60 | 60% | 40% | More distributed ranking |
| 0.75 | 75% | 25% | Greater influence of graph structure |
| 0.85 | 85% | 15% | Standard PageRank setting |
| 0.95 | 95% | 5% | Strong concentration |
| 1.00 | 100% | 0% | Entirely determined by hyperlinks |
As
For every value of
- X-axis: Webpage index
- Y-axis: PageRank value
The experiments demonstrate that the damping parameter has a significant effect on the PageRank distribution.
For smaller values of
For the primary setting http://www.makeinindia.com with a PageRank of 0.057644.
The results also show that PageRank is not determined solely by the number of incoming links — the importance of the webpages providing those links also matters. The
A webpage can obtain a high PageRank when:
- It receives many incoming hyperlinks.
- The webpages linking to it have high PageRank.
- It belongs to a strongly connected or highly influential region of the graph.
- Probability mass flows toward it through the hyperlink structure.
PageRank therefore measures more than simple hyperlink counts — it recursively assigns importance based on the importance of neighboring webpages.