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

Add PageRank #788

Merged
merged 33 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d32d265
Add the sketch of PageRank
IvanIsCoding Jan 22, 2023
a4de4e7
More progress towards pagerank
IvanIsCoding Jan 22, 2023
e099998
Use CentralityMapping and FailedToConverge
IvanIsCoding Jan 22, 2023
92bb4f6
Finalize PageRank
IvanIsCoding Jan 23, 2023
2041cfc
First test does not run
IvanIsCoding Jan 23, 2023
fa35e90
Remove unwanted triplet
IvanIsCoding Jan 23, 2023
1ce674a
Fix clippy warning
IvanIsCoding Jan 23, 2023
8f569f5
Handle personalization correctly
IvanIsCoding Jan 23, 2023
03df46f
Add more tests
IvanIsCoding Jan 23, 2023
eb0dc24
Cargo fmt
IvanIsCoding Jan 23, 2023
428715f
Add scipy to test requirements
IvanIsCoding Jan 23, 2023
bdf45af
Skip SciPy tests in case architecture does not have it
IvanIsCoding Jan 23, 2023
b270e9a
Ignore flake8 errors that do not help
IvanIsCoding Jan 23, 2023
9cf13b5
Flake8
IvanIsCoding Jan 23, 2023
d025677
Handle dangling weights
IvanIsCoding Jan 24, 2023
47df879
Add more tests
IvanIsCoding Jan 24, 2023
5f98164
Add nstart argument
IvanIsCoding Jan 24, 2023
36bda8d
Cargo Clippy
IvanIsCoding Jan 24, 2023
4e139f8
Documentation
IvanIsCoding Jan 24, 2023
3e54cb5
Fix typo in URL
IvanIsCoding Jan 24, 2023
0480034
Merge branch 'main' into pagerank
IvanIsCoding Jan 27, 2023
45a63a1
Merge branch 'main' into pagerank
IvanIsCoding Jan 29, 2023
7f953d8
Update releasenotes/notes/add-pagerank-bef0de7d46026071.yaml
IvanIsCoding Feb 1, 2023
641c8e5
Merge remote-tracking branch 'upstream/main' into pagerank
IvanIsCoding Feb 1, 2023
a125b86
Tweak pyfunction signature
IvanIsCoding Feb 1, 2023
d4a25ca
Add scipy to aarch64 test requirements
IvanIsCoding Feb 1, 2023
3b6c6e7
Merge remote-tracking branch 'origin/main' into pagerank
IvanIsCoding Mar 21, 2023
bc9a720
Merge branch 'main' into pagerank
IvanIsCoding Mar 23, 2023
15323c0
Merge branch 'main' into pagerank
IvanIsCoding Apr 15, 2023
f7e2f41
Merge branch 'main' into pagerank
IvanIsCoding May 12, 2023
56017e8
Merge remote-tracking branch 'upstream/main' into pagerank
IvanIsCoding May 26, 2023
e0369e0
Address comments from code review
IvanIsCoding May 26, 2023
efd954a
Clippy is always right
IvanIsCoding May 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ jobs:
- name: Download grcov
run: curl -L https://github.com/mozilla/grcov/releases/download/v0.8.7/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf -
- name: Install deps
run: pip install -U setuptools-rust networkx testtools fixtures
run: pip install -U setuptools-rust networkx scipy testtools fixtures
- name: Build retworkx
run: python setup.py develop
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
CIBW_MANYLINUX_I686_IMAGE: quay.io/pypa/manylinux2014_i686:latest
CIBW_SKIP: cp36-* pp* *win32 *musl*
CIBW_BEFORE_BUILD: pip install -U setuptools-rust
CIBW_TEST_REQUIRES: networkx testtools fixtures
CIBW_TEST_REQUIRES: networkx scipy testtools fixtures
IvanIsCoding marked this conversation as resolved.
Show resolved Hide resolved
CIBW_TEST_COMMAND: python -m unittest discover {project}/tests/rustworkx_tests
- uses: actions/upload-artifact@v2
with:
Expand Down
95 changes: 91 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ rayon = "1.6"
num-traits = "0.2"
num-bigint = "0.4"
num-complex = "0.4"
ndarray-stats = "0.5.1"
quick-xml = "0.22.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand All @@ -50,6 +51,10 @@ features = ["rayon"]
version = "1.7"
features = ["rayon"]

[dependencies.sprs]
version = "^0.11"
features = ["multi_thread"]

[profile.release]
lto = 'fat'
codegen-units = 1
10 changes: 10 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ Centrality
rustworkx.betweenness_centrality
rustworkx.eigenvector_centrality

.. _link-analysis:

Link Analysis
--------------

.. autosummary::
:toctree: apiref

rustworkx.pagerank

.. _traversal:

Traversal
Expand Down
29 changes: 29 additions & 0 deletions releasenotes/notes/add-pagerank-bef0de7d46026071.yaml
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
IvanIsCoding marked this conversation as resolved.
Show resolved Hide resolved
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)
)

mtreinish marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ mod isomorphism;
mod iterators;
mod json;
mod layout;
mod link_analysis;
mod matching;
mod planar;
mod random_graph;
Expand All @@ -46,6 +47,8 @@ use graphml::*;
use isomorphism::*;
use json::*;
use layout::*;
use link_analysis::*;

use matching::*;
use planar::*;
use random_graph::*;
Expand Down Expand Up @@ -477,6 +480,7 @@ fn rustworkx(py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(read_graphml))?;
m.add_wrapped(wrap_pyfunction!(digraph_node_link_json))?;
m.add_wrapped(wrap_pyfunction!(graph_node_link_json))?;
m.add_wrapped(wrap_pyfunction!(pagerank))?;
m.add_class::<digraph::PyDiGraph>()?;
m.add_class::<graph::PyGraph>()?;
m.add_class::<toposort::TopologicalSorter>()?;
Expand Down
Loading