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
Page Rank algorithm implementation for Graphs #27480
Comments
comment:2
I have a brief idea about it(used it in my college project) and can implement it in Sage modules. |
comment:3
I just found that networkx library already has Page Rank algorithm implemented in Python. Should I implement it in Sage freshly or should I make a function to use networkx implementation ? |
comment:4
networkx has several methods to compute Page rank: a pure Python, one using numpy, another using scipy, etc. The optional package The best thing to do is to create a method including a parameter |
comment:5
When it is None, should an implementation in sage be used? And if so should I do an implementation |
comment:6
When it's Before deciding if a new implementation is needed, we must know if what we can easily get is fast enough or not. |
Branch: u/gh-rajat1433/27480_page_rank |
Dependencies: #27496 |
comment:9
I have installed igraph in my sage module. But however its pagerank algorithm is not able to work. It keeps on throwing a segmentation error. I use igraph_graph to convert sage graph into igraph. All other algorithms of igraph works fine. Following error message I get:
Regarding networkx,numpy and scipy, I have tested them on their runtime. Numpy does it by matrix multiplication and solving for eigenvalues, networkx has pure python implementation and scipy does matrix multiplication iteratively. Following are the runtimes I got:
As per my analysis upto around 60 vertices numpy is fast but scipy is fastest after that. |
comment:10
I don't know what's the problem with igraph. I have installed
Try recompiling sage ( |
comment:11
Note that a random graph on 40 nodes with probability 0.01 has in average 8 edges... so your experiments are not very conclusive on small graphs. Nonetheless, |
comment:12
More experiments with dense small graphs also suggest numpy to be best for small graphs
|
comment:13
Ticket retargeted after milestone closed (if you don't believe this ticket is appropriate for the Sage 8.8 release please retarget manually) |
comment:15
Page rank for Ipython with weighted edges doesn't seem to be working: https://github.com/igraph/python-igraph/blob/master/src/graphobject.c https://igraph.org/python/doc/igraph.GraphBase-class.html#personalized_pagerank
|
comment:16
Following experiments show igraph's results to be the best due to its c-language code.
|
comment:17
The code of the pagerank algorithm is here https://github.com/igraph/igraph/blob/master/src/centrality.c |
Changed branch from u/gh-rajat1433/27480_page_rank to u/gh-rajat1433/27480_page_rank_implementation |
Commit: |
Changed branch from u/gh-rajat1433/27480_page_rank_implementation to u/gh-rajat1433/27480_page_rank_algo |
Changed commit from |
Commit: |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:65
Done the changes! |
comment:66
LGTM. |
Changed branch from u/gh-rajat1433/27480_page_rank_algo to |
Changed branch from |
comment:68
|
comment:69
- sage: G.pagerank(alpha=0.50, algorithm="igraph")
+ sage: G.pagerank(alpha=0.50, algorithm="igraph") # optional - python_igraph
{0: 0.25, 1: 0.25, 2: 0.24999999999999997, 3: 0.24999999999999997} and - sage: G.pagerank(algorithm="igraph")
+ sage: G.pagerank(algorithm="igraph") # optional - python_igraph
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:71
Added the optional igraph thing. |
comment:73
On my system all tests passes but patchbot has some failed examples don't know why... |
comment:74
This is numerical noise due to floating point arithmetic. See http://doc.sagemath.org/html/en/developer/coding_basics.html#special-markup-to-influence-doctests A solution is to add - sage: G.pagerank(algorithm="Numpy")
+ sage: G.pagerank(algorithm="Numpy") # abs tol 1e-9 ... - sage: G.pagerank()
+ sage: G.pagerank() # abs tol 1e-9 also for - sage: G.pagerank(alpha=0.50, algorithm="igraph") # optional - python_igraph
+ sage: G.pagerank(alpha=0.50, algorithm="igraph") # optional - python_igraph # abs tol 1e-9 |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:76
LGTM |
Changed branch from u/gh-rajat1433/27480_page_rank_algo to |
comment:78
There is an issue with igraph on the arando patchbot with 8.8.b4 and 8.8.b5:
|
Changed commit from |
comment:79
I think I forgot to add # abs tol 1e-9 to this test. Thanks David for opening #27811 for fixing it Replying to @fchapoton:
|
Page Rank computes the ranking of the nodes of the graph based on the structure of the incoming links. It is a useful metrics in graphs and can be quite useful. (https://towardsdatascience.com/graphs-and-paths-pagerank-54f180a1aa0a)
Below is a link to a thesis on this algorithm
http://www.sagemath.org/files/thesis/augeri-thesis-2008.pdf
It would be good to have its implementation in the Sage's graph module.
CC: @dcoudert
Component: graph theory
Keywords: pagerank
Author: Rajat Mittal
Branch:
07a884b
Reviewer: David Coudert
Issue created by migration from https://trac.sagemath.org/ticket/27480
The text was updated successfully, but these errors were encountered: