Metadata-Version: 2.1
Name: rustpyppr
Version: 0.1.2
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

# Personalized PageRank in Rust for Python
This small library provides efficient functions for Python to compute [Personalized PageRank](https://arxiv.org/abs/2006.11876)
scores in a graph. Personalized PageRank is similar to ordinary [PageRank](https://en.wikipedia.org/wiki/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.
```python
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}}


```
