-
Notifications
You must be signed in to change notification settings - Fork 255
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
Conversation
There was a problem hiding this 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.
plt.title("Graph with Personalized PageRank") | ||
plt.show() |
There was a problem hiding this comment.
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.
# %% | ||
# Then we set the nodes to prioritize, for example nodes with indices ``0`` and ``6``: | ||
reset_vector[0] = 1 | ||
reset_vector[6] = 1 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
Co-authored-by: Szabolcs Horvát <[email protected]>
This PR implements a tutorial for calculating and visualizing personalized PageRank on a grid, as suggested here.