{"id":16750462,"url":"https://github.com/mberr/torch-ppr","last_synced_at":"2025-07-17T05:41:16.262Z","repository":{"id":37408893,"uuid":"489278230","full_name":"mberr/torch-ppr","owner":"mberr","description":"(Personalized) Page-Rank computation using PyTorch","archived":false,"fork":false,"pushed_at":"2022-11-30T09:46:11.000Z","size":96,"stargazers_count":90,"open_issues_count":3,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-09T01:47:35.380Z","etag":null,"topics":["gpu","pagerank","personalized-pagerank","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mberr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-06T08:35:01.000Z","updated_at":"2025-05-03T10:02:54.000Z","dependencies_parsed_at":"2023-01-21T13:16:27.800Z","dependency_job_id":null,"html_url":"https://github.com/mberr/torch-ppr","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mberr%2Ftorch-ppr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mberr%2Ftorch-ppr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mberr%2Ftorch-ppr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mberr%2Ftorch-ppr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mberr","download_url":"https://codeload.github.com/mberr/torch-ppr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253176440,"owners_count":21866142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gpu","pagerank","personalized-pagerank","pytorch"],"created_at":"2024-10-13T02:28:13.624Z","updated_at":"2025-05-09T01:47:42.641Z","avatar_url":"https://github.com/mberr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/mberr/torch-ppr/raw/main/docs/source/logo.png\" height=\"150\"\u003e\n\u003c/p\u003e\n--\u003e\n\n\u003ch1 align=\"center\"\u003e\n  torch-ppr\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/mberr/torch-ppr/actions?query=workflow%3ATests\"\u003e\n        \u003cimg alt=\"Tests\" src=\"https://github.com/mberr/torch-ppr/workflows/Tests/badge.svg\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://pypi.org/project/torch_ppr\"\u003e\n        \u003cimg alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/torch_ppr\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://pypi.org/project/torch_ppr\"\u003e\n        \u003cimg alt=\"PyPI - Python Version\" src=\"https://img.shields.io/pypi/pyversions/torch_ppr\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/mberr/torch-ppr/blob/main/LICENSE\"\u003e\n        \u003cimg alt=\"PyPI - License\" src=\"https://img.shields.io/pypi/l/torch_ppr\" /\u003e\n    \u003c/a\u003e\n    \u003ca href='https://torch_ppr.readthedocs.io/en/latest/?badge=latest'\u003e\n        \u003cimg src='https://readthedocs.org/projects/torch_ppr/badge/?version=latest' alt='Documentation Status' /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://codecov.io/gh/mberr/torch-ppr/branch/main\"\u003e\n        \u003cimg src=\"https://codecov.io/gh/mberr/torch-ppr/branch/main/graph/badge.svg\" alt=\"Codecov status\" /\u003e\n    \u003c/a\u003e  \n    \u003ca href=\"https://github.com/cthoyt/cookiecutter-python-package\"\u003e\n        \u003cimg alt=\"Cookiecutter template from @cthoyt\" src=\"https://img.shields.io/badge/Cookiecutter-snekpack-blue\" /\u003e \n    \u003c/a\u003e\n    \u003ca href='https://github.com/psf/black'\u003e\n        \u003cimg src='https://img.shields.io/badge/code%20style-black-000000.svg' alt='Code style: black' /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/mberr/torch-ppr/blob/main/.github/CODE_OF_CONDUCT.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg\" alt=\"Contributor Covenant\"/\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\nThis package allows calculating page-rank and personalized page-rank via power iteration with PyTorch,\nwhich also supports calculation on GPU (or other accelerators).\n\n## 💪 Getting Started\n\nAs a simple example, consider this simple graph with five nodes.\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/source/img/small_graph.svg\" height=\"300\"\u003e\n\u003c/p\u003e\n\nIts edge list is given as\n```python-console\n\u003e\u003e\u003e import torch\n\u003e\u003e\u003e edge_index = torch.as_tensor(data=[(0, 1), (1, 2), (1, 3), (2, 4)]).t()\n```\n\nWe can use\n```python-console\n\u003e\u003e\u003e from torch_ppr import page_rank\n\u003e\u003e\u003e page_rank(edge_index=edge_index)\ntensor([0.1269, 0.3694, 0.2486, 0.1269, 0.1281])\n```\nto calculate the page rank, i.e., a measure of global importance.\nWe notice that the central node receives the largest importance score,\nwhile all other nodes have lower importance. Moreover, the two\nindistinguishable nodes `0` and `3` receive the same page rank.\n\nWe can also calculate *personalized* page rank which measures importance\nfrom the perspective of a single node.\nFor instance, for node `2`, we have\n```python-console\n\u003e\u003e\u003e from torch_ppr import personalized_page_rank\n\u003e\u003e\u003e personalized_page_rank(edge_index=edge_index, indices=[2])\ntensor([[0.1103, 0.3484, 0.2922, 0.1103, 0.1388]])\n```\nThus, the most important node is the central node `1`, nodes `0` and `3` receive\nthe same importance value which is below the value of the direct neighbor `4`.\n\nBy the virtue of using PyTorch, the code seamlessly works on GPUs, too, and\nsupports auto-grad differentiation. Moreover, the calculation of personalized\npage rank supports automatic batch size optimization via\n[`torch_max_mem`](https://github.com/mberr/torch-max-mem).\n\n## 🚀 Installation\n\nThe most recent release can be installed from\n[PyPI](https://pypi.org/project/torch_ppr/) with:\n\n```bash\n$ pip install torch_ppr\n```\n\nThe most recent code and data can be installed directly from GitHub with:\n\n```bash\n$ pip install git+https://github.com/mberr/torch-ppr.git\n```\n\n## 👐 Contributing\n\nContributions, whether filing an issue, making a pull request, or forking, are appreciated. See\n[CONTRIBUTING.md](https://github.com/mberr/torch-ppr/blob/master/.github/CONTRIBUTING.md) for more information on getting involved.\n\n## 👋 Attribution\n\n### ⚖️ License\n\nThe code in this package is licensed under the MIT License.\n\n\u003c!--\n### 📖 Citation\n\nCitation goes here!\n--\u003e\n\n\u003c!--\n### 🎁 Support\n\nThis project has been supported by the following organizations (in alphabetical order):\n\n- [Harvard Program in Therapeutic Science - Laboratory of Systems Pharmacology](https://hits.harvard.edu/the-program/laboratory-of-systems-pharmacology/)\n\n--\u003e\n\n\u003c!--\n### 💰 Funding\n\nThis project has been supported by the following grants:\n\n| Funding Body                                             | Program                                                                                                                       | Grant           |\n|----------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|-----------------|\n| DARPA                                                    | [Automating Scientific Knowledge Extraction (ASKE)](https://www.darpa.mil/program/automating-scientific-knowledge-extraction) | HR00111990009   |\n--\u003e\n\n### 🍪 Cookiecutter\n\nThis package was created with [@audreyfeldroy](https://github.com/audreyfeldroy)'s\n[cookiecutter](https://github.com/cookiecutter/cookiecutter) package using [@cthoyt](https://github.com/cthoyt)'s\n[cookiecutter-snekpack](https://github.com/cthoyt/cookiecutter-snekpack) template.\n\n## 🛠️ For Developers\n\n\u003cdetails\u003e\n  \u003csummary\u003eSee developer instructions\u003c/summary\u003e\n\n\nThe final section of the README is for if you want to get involved by making a code contribution.\n\n### Development Installation\n\nTo install in development mode, use the following:\n\n```bash\n$ git clone git+https://github.com/mberr/torch-ppr.git\n$ cd torch-ppr\n$ pip install -e .\n```\n\n### 🥼 Testing\n\nAfter cloning the repository and installing `tox` with `pip install tox`, the unit tests in the `tests/` folder can be\nrun reproducibly with:\n\n```shell\n$ tox\n```\n\nAdditionally, these tests are automatically re-run with each commit in a [GitHub Action](https://github.com/mberr/torch-ppr/actions?query=workflow%3ATests).\n\n### 📖 Building the Documentation\n\nThe documentation can be built locally using the following:\n\n```shell\n$ git clone git+https://github.com/mberr/torch-ppr.git\n$ cd torch-ppr\n$ tox -e docs\n$ open docs/build/html/index.html\n``` \n\nThe documentation automatically installs the package as well as the `docs`\nextra specified in the [`setup.cfg`](setup.cfg). `sphinx` plugins\nlike `texext` can be added there. Additionally, they need to be added to the\n`extensions` list in [`docs/source/conf.py`](docs/source/conf.py).\n\n### 📦 Making a Release\n\nAfter installing the package in development mode and installing\n`tox` with `pip install tox`, the commands for making a new release are contained within the `finish` environment\nin `tox.ini`. Run the following from the shell:\n\n```shell\n$ tox -e finish\n```\n\nThis script does the following:\n\n1. Uses [Bump2Version](https://github.com/c4urself/bump2version) to switch the version number in the `setup.cfg`,\n   `src/torch_ppr/version.py`, and [`docs/source/conf.py`](docs/source/conf.py) to not have the `-dev` suffix\n2. Packages the code in both a tar archive and a wheel using [`build`](https://github.com/pypa/build)\n3. Uploads to PyPI using [`twine`](https://github.com/pypa/twine). Be sure to have a `.pypirc` file configured to avoid the need for manual input at this\n   step\n4. Push to GitHub. You'll need to make a release going with the commit where the version was bumped.\n5. Bump the version to the next patch. If you made big changes and want to bump the version by minor, you can\n   use `tox -e bumpversion minor` after.\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmberr%2Ftorch-ppr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmberr%2Ftorch-ppr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmberr%2Ftorch-ppr/lists"}