Skip to main content

No project description provided

Project description

Personalized PageRank in Rust for Python

This small library provides efficient functions for Python to compute Personalized PageRank scores in a graph. Personalized PageRank is similar to ordinary PageRank but the node where the random surfer will start from (after a teleportation or in the beginning) is not sampled uniformly from all the nodes, but rather from a smaller subset of them. This subset, which is called Personalized Set, must contain at least 1 node.

The implemented algorithms so far are various versions of Forward Push for single source. This means that given a source node, it is possible to compute the PPR scores of other ones w.r.t. the source node.

Getting Started

At the moment, we did not publish the wheel on pypi yet. After cloning this repository, you can manually build the wheel and install it.

pip install maturin
maturin build --release
pip install target/wheels/rustpyppr-[ wheel version and parameters here ]

After the installation, you can simply import it from python and use it.

import rustpyppr

graph = {3:[5, 1], 1:[3], 5:[3]}
source = 3
ppr = rustpyppr.forward_push(graph, source)
print(f'{ppr = }')
# ppr = {1: 0.22936248564736167, 3: 0.5412750287052767, 5: 0.22936248564736167}

# you can also run PPR on multiple sources in the same graph in parallel with native multithreading
sources = [3, 1]
ppr = rustpyppr.multiple_forward_push(graph, sources)
print(f'{ppr = }')
# ppr = {1: {1: 0.34579401171205487, 5: 0.19511406668236952, 3: 0.45909192160557544}, 3: {3: 0.5412750287052767, 5: 0.22936248564736167, 1: 0.22936248564736167}}

# and finally, you can run PPR on different graphs with different sources (also using multithreading)
graphs = [{2:[0], 0:[2]}, {3:[5, 1], 1:[3], 5:[3]}]
sources = [2, 5]
ppr = rustpyppr.parallel_forward_push(graphs, sources)
print(f'{ppr = }')
# ppr = {5: {3: 0.45909192160557544, 1: 0.19511406668236952, 5: 0.34579401171205487}, 2: {0: 0.4587249712947233, 2: 0.5412750287052767}}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rustpyppr-0.1.2-cp311-cp311-manylinux_2_34_x86_64.whl (244.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

File details

Details for the file rustpyppr-0.1.2-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rustpyppr-0.1.2-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a7e3cfeccaa97a87e1b1fffa7ae70ec1dc6235bf89b8a898c72d4f590742a4d8
MD5 ce80adfbbc9c5edda17f2d4cc6cd87b7
BLAKE2b-256 a0ef365ab111f5e2fa6433f7b2308f3e0b0b27fafc88430132381b4871477738

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page