{"id":17526854,"url":"https://github.com/networkx/nx-parallel","last_synced_at":"2025-04-05T09:04:50.483Z","repository":{"id":177081086,"uuid":"653928546","full_name":"networkx/nx-parallel","owner":"networkx","description":"A networkx backend that uses joblib to run graph algorithms in parallel.","archived":false,"fork":false,"pushed_at":"2025-03-26T07:33:57.000Z","size":2260,"stargazers_count":50,"open_issues_count":22,"forks_count":30,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-02T01:15:49.766Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/networkx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["networkx"],"open_collective":"networkx"}},"created_at":"2023-06-15T03:35:23.000Z","updated_at":"2025-03-26T07:43:12.000Z","dependencies_parsed_at":"2023-10-14T20:15:19.393Z","dependency_job_id":"5901f6d4-2b25-4b07-bdbe-a1858383fe24","html_url":"https://github.com/networkx/nx-parallel","commit_stats":{"total_commits":118,"total_committers":11,"mean_commits":"10.727272727272727","dds":0.6016949152542372,"last_synced_commit":"14ad5ab053d218e49a375f756f5ec025dd16ab16"},"previous_names":["networkx/nx_parallel","networkx/nx-parallel"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networkx%2Fnx-parallel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networkx%2Fnx-parallel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networkx%2Fnx-parallel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/networkx%2Fnx-parallel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/networkx","download_url":"https://codeload.github.com/networkx/nx-parallel/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246856583,"owners_count":20844974,"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":[],"created_at":"2024-10-20T15:02:34.237Z","updated_at":"2025-04-05T09:04:50.424Z","avatar_url":"https://github.com/networkx.png","language":"Python","funding_links":["https://github.com/sponsors/networkx","https://opencollective.com/networkx"],"categories":["Python"],"sub_categories":[],"readme":"# nx-parallel\n\nnx-parallel is a NetworkX backend that uses joblib for parallelization. This project aims to provide parallelized implementations of various NetworkX functions to improve performance. Refer [NetworkX backends documentation](https://networkx.org/documentation/latest/reference/backends.html) to learn more about the backend architecture in NetworkX.\n\n## Algorithms in nx-parallel\n\n- [all_pairs_all_shortest_paths](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/generic.py#L11)\n- [all_pairs_bellman_ford_path](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/weighted.py#L212)\n- [all_pairs_bellman_ford_path_length](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/weighted.py#L168)\n- [all_pairs_dijkstra](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/weighted.py#L29)\n- [all_pairs_dijkstra_path](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/weighted.py#L124)\n- [all_pairs_dijkstra_path_length](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/weighted.py#L73)\n- [all_pairs_node_connectivity](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/connectivity/connectivity.py#L18)\n- [all_pairs_shortest_path](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/unweighted.py#L63)\n- [all_pairs_shortest_path_length](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/unweighted.py#L19)\n- [approximate_all_pairs_node_connectivity](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/approximation/connectivity.py#L13)\n- [betweenness_centrality](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/centrality/betweenness.py#L20)\n- [closeness_vitality](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/vitality.py#L10)\n- [edge_betweenness_centrality](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/centrality/betweenness.py#L96)\n- [is_reachable](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/tournament.py#L13)\n- [johnson](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/weighted.py#L256)\n- [local_efficiency](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/efficiency_measures.py#L10)\n- [node_redundancy](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/bipartite/redundancy.py#L12)\n- [number_of_isolates](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/isolate.py#L9)\n- [square_clustering](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/cluster.py#L11)\n- [tournament_is_strongly_connected](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/tournament.py#L59)\n\n\u003cdetails\u003e\n\u003csummary\u003eScript used to generate the above list\u003c/summary\u003e\n  \n```\nimport _nx_parallel as nxp\nd = nxp.get_funcs_info() # temporarily add `from .update_get_info import *` to _nx_parallel/__init__.py\nfor func in d:\n    print(f\"- [{func}]({d[func]['url']})\")\n```\n\n\u003c/details\u003e\n\n## Installation\n\nIt is recommended to first refer the [NetworkX's INSTALL.rst](https://github.com/networkx/networkx/blob/main/INSTALL.rst).\nnx-parallel requires Python \u003e=3.11. Right now, the only dependencies of nx-parallel are networkx and joblib.\n\n### Installing nx-parallel using `pip`\n\nYou can install the stable version of nx-parallel using pip:\n\n```sh\npip install nx-parallel\n```\n\nThe above command also installs the two main dependencies of nx-parallel i.e. networkx\nand joblib. To upgrade to a newer release use the `--upgrade` flag:\n\n```sh\npip install --upgrade nx-parallel\n```\n\n### Installing the development version\n\nBefore installing the development version, you may need to uninstall the\nstandard version of `nx-parallel` and other two dependencies using `pip`:\n\n```sh\npip uninstall nx-parallel networkx joblib\n```\n\nThen do:\n\n```sh\npip install git+https://github.com/networkx/nx-parallel.git@main\n```\n\n### Installing nx-parallel with conda\n\nInstalling `nx-parallel` from the `conda-forge` channel can be achieved by adding `conda-forge` to your channels with:\n\n```sh\nconda config --add channels conda-forge\nconda config --set channel_priority strict\n```\n\nOnce the `conda-forge` channel has been enabled, `nx-parallel` can be installed with `conda`:\n\n```sh\nconda install nx-parallel\n```\n\nor with `mamba`:\n\n```sh\nmamba install nx-parallel\n```\n\n## Backend usage\n\nYou can run your networkx code by just setting the `NETWORKX_AUTOMATIC_BACKENDS` environment variable to `parallel`:\n\n```sh\nexport NETWORKX_AUTOMATIC_BACKENDS=parallel \u0026\u0026 python nx_code.py\n```\n\nNote that for all functions inside `nx_code.py` that do not have an nx-parallel implementation their original networkx implementation will be executed. You can also use the nx-parallel backend in your code for only some specific function calls in the following ways:\n\n```py\nimport networkx as nx\nimport nx_parallel as nxp\n\n# enabling networkx's config for nx-parallel\nnx.config.backends.parallel.active = True\n\n# setting `n_jobs` (by default, `n_jobs=None`)\nnx.config.backends.parallel.n_jobs = 4\n\nG = nx.path_graph(4)\nH = nxp.ParallelGraph(G)\n\n# method 1 : passing ParallelGraph object in networkx function (Type-based dispatching)\nnx.betweenness_centrality(H)\n\n# method 2 : using the 'backend' kwarg\nnx.betweenness_centrality(G, backend=\"parallel\")\n\n# method 3 : using nx-parallel implementation with networkx object\nnxp.betweenness_centrality(G)\n\n# method 4 : using nx-parallel implementation with ParallelGraph object\nnxp.betweenness_centrality(H)\n```\n\nFor more on how to play with configurations in nx-parallel refer the [Config.md](./Config.md)! Additionally, refer the [NetworkX's official backend and config docs](https://networkx.org/documentation/latest/reference/backends.html) for more on functionalities provided by networkx for backends and configs like logging, `backend_priority`, etc. Another way to configure nx-parallel is by using [`joblib.parallel_config`](https://joblib.readthedocs.io/en/latest/generated/joblib.parallel_config.html).\n\n### Notes\n\n1. Some functions in networkx have the same name but different implementations, so to avoid these name conflicts at the time of dispatching networkx differentiates them by specifying the `name` parameter in the `_dispatchable` decorator of such algorithms. So, `method 3` and `method 4` are not recommended. But, you can use them if you know the correct `name`. For example:\n\n   ```py\n   # using `name` parameter - nx-parallel as an independent package\n\n   # run the parallel implementation in `connectivity/connectivity`\n   nxp.all_pairs_node_connectivity(H)\n\n   # runs the parallel implementation in `approximation/connectivity`\n   nxp.approximate_all_pairs_node_connectivity(H)\n   ```\n\n   Also, if you are using nx-parallel as a backend then mentioning the subpackage to which the algorithm belongs is recommended to ensure that networkx dispatches to the correct implementation. For example:\n\n   ```py\n   # with subpackage - nx-parallel as a backend\n   nx.all_pairs_node_connectivity(H)\n   nx.approximation.all_pairs_node_connectivity(H)\n   ```\n\n2. Right now there isn't much difference between `nx.Graph` and `nxp.ParallelGraph` so `method 3` would work fine but it is not recommended because in the future that might not be the case.\n\nFeel free to contribute to nx-parallel. You can find the contributing guidelines [here](./CONTRIBUTING.md). If you'd like to implement a feature or fix a bug, we'd be happy to review a pull request. Please make sure to explain the changes you made in the pull request description. And feel free to open issues for any problems you face, or for new features you'd like to see implemented.\n\nThis project is managed under the NetworkX organisation, so the [code of conduct of NetworkX](https://github.com/networkx/networkx/blob/main/CODE_OF_CONDUCT.rst) applies here as well.\n\nAll code in this repository is available under the Berkeley Software Distribution (BSD) 3-Clause License (see LICENSE).\n\nThank you :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetworkx%2Fnx-parallel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetworkx%2Fnx-parallel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetworkx%2Fnx-parallel/lists"}