-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Related to #315 Adds an implementation of the PageRank algorithm using sparse matrices. It uses the sprs crate combined with ndarray to implement a Power Method approach of finding the PageRank. Also, we test this implementation against NetworkX's implementation of the PageRank. We accept all the arguments that NetworkX accepts: tolerance, max_iter, personalization, dangling, etc. * Add the sketch of PageRank * More progress towards pagerank * Use CentralityMapping and FailedToConverge * Finalize PageRank * First test does not run * Remove unwanted triplet * Fix clippy warning * Handle personalization correctly * Add more tests * Cargo fmt * Add scipy to test requirements * Skip SciPy tests in case architecture does not have it * Ignore flake8 errors that do not help * Flake8 * Handle dangling weights * Add more tests * Add nstart argument * Cargo Clippy * Documentation * Fix typo in URL * Update releasenotes/notes/add-pagerank-bef0de7d46026071.yaml Co-authored-by: Matthew Treinish <[email protected]> * Tweak pyfunction signature * Add scipy to aarch64 test requirements * Address comments from code review * Clippy is always right --------- Co-authored-by: Matthew Treinish <[email protected]>
- Loading branch information
1 parent
09d5707
commit afc3627
Showing
10 changed files
with
597 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
features: | ||
- | | ||
Added a new function, :func:`~.pagerank` which is used to | ||
compute the PageRank score for all nodes in a given directed graph. | ||
For example: | ||
.. jupyter-execute:: | ||
import rustworkx as rx | ||
from rustworkx.visualization import mpl_draw | ||
graph = rx.generators.directed_hexagonal_lattice_graph(2, 2) | ||
ranks = rx.pagerank(graph) | ||
# Generate a color list | ||
colors = [] | ||
for node in graph.node_indices(): | ||
pagerank_score = ranks[node] | ||
graph[node] = pagerank_score | ||
colors.append(pagerank_score) | ||
mpl_draw( | ||
graph, | ||
with_labels=True, | ||
node_color=colors, | ||
node_size=650, | ||
labels=lambda x: "{0:.2f}".format(x) | ||
) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.