Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add personalized PageRank on a grid tutorial #821

Merged
merged 3 commits into from
Mar 31, 2025

Conversation

BeaMarton13
Copy link
Contributor

This PR implements a tutorial for calculating and visualizing personalized PageRank on a grid, as suggested here.

  • By submitting this pull request, I assign the copyright of my contribution to The igraph development team.

@BeaMarton13 BeaMarton13 changed the title docs: add personalized PageRank tutorial docs: add personalized PageRank on a grid tutorial Mar 26, 2025
Copy link
Member

@szhorvat szhorvat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, well done!

Could you add a very short explanation, perhaps a "note", about what PageRank is? The PageRank score of a vertex is the frequency with which a random walker traverses that vertex. After each step, the walker has a 1 - damping chance to restart the walk, picking a starting vertices with probabilities given in the reset vector.

Comment on lines 56 to 57
plt.title("Graph with Personalized PageRank")
plt.show()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make the plot not be stretched vertically or horizontally. Something like plt.axis("equal") can achieve this.

Comment on lines 70 to 73
# %%
# Then we set the nodes to prioritize, for example nodes with indices ``0`` and ``6``:
reset_vector[0] = 1
reset_vector[6] = 1
Copy link
Member

@szhorvat szhorvat Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's choose two nodes that are a bit further from each other, and give one of them a higher weight than the other. This will make a more interesting plot.

Alternatively, use the reset_vertices parameter and pass in the vertices. They will have equal weights in this case.

It's your choice which pattern you demonstrate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ntamas In IGraph/M I allow reset_vertices to be a dictionary. They keys are vertices and the values are reset weights. What do you think about implementing the same for python-igraph, assuming that @BeaMarton13 is interested in doing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely, we can try to do it.


# %%
# Then we calculate the personalized PageRank:
personalized_page_rank = g.personalized_pagerank(weights=None, damping=0.85, reset=reset_vector)
Copy link
Member

@szhorvat szhorvat Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove weights here since there are no weights to think about. You can choose to tune the damping to make the plot look more interesting. Even if you leave it at the default of 0.85, do keep the damping parameter, as this is something people may want to play with.

You could even choose to show two plots with two different damping values, to illustrate the effect of this parameter.

@szhorvat szhorvat marked this pull request as ready for review March 31, 2025 22:34
@szhorvat szhorvat merged commit e182398 into igraph:main Mar 31, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants