Skip to content
Merged
Changes from 5 commits
Commits
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
54 changes: 40 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ nx-parallel is a NetworkX backend that uses joblib for parallelization. This pro
<details>
<summary>Script used to generate the above list</summary>

```.py
```py
import _nx_parallel as nxp
d = nxp.get_funcs_info() # temporarily add `from .update_get_info import *` to _nx_parallel/__init__.py
# temporarily add `from .update_get_info import *` to _nx_parallel/__init__.py
d = nxp.get_funcs_info()
for func in d:
print(f"- [{func}]({d[func]['url']})")
```
Expand All @@ -42,47 +43,68 @@ for func in d:
It is recommended to first refer the [NetworkX's INSTALL.rst](https://github.com/networkx/networkx/blob/main/INSTALL.rst).
nx-parallel requires Python >=3.10. Right now, the only dependencies of nx-parallel are networkx and joblib.

### Install the released version
### Installing nx-parallel using `pip`

You can install the stable version of nx-parallel using pip:

```sh
$ pip install nx-parallel
pip install nx-parallel
```

The above command also installs the two main dependencies of nx-parallel i.e. networkx
and joblib. To upgrade to a newer release use the `--upgrade` flag:

```sh
$ pip install --upgrade nx-parallel
pip install --upgrade nx-parallel
```

### Install the development version
### Installing the development version

Before installing the development version, you may need to uninstall the
standard version of `nx-parallel` and other two dependencies using `pip`:

```sh
$ pip uninstall nx-parallel networkx joblib
pip uninstall nx-parallel networkx joblib
```

Then do:

```sh
$ pip install git+https://github.com/networkx/nx-parallel.git@main
pip install git+https://github.com/networkx/nx-parallel.git@main
```

### Installing nx-parallel with conda

Installing `nx-parallel` from the `conda-forge` channel can be achieved by adding `conda-forge` to your channels with:

```sh
conda config --add channels conda-forge
conda config --set channel_priority strict
```

Once the `conda-forge` channel has been enabled, `nx-parallel` can be installed with `conda`:

```sh
conda install nx-parallel
```

or with `mamba`:

```sh
mamba install nx-parallel
```

## Backend usage

You can run your networkx code by just setting the `NETWORKX_AUTOMATIC_BACKENDS` environment variable to `parallel`:

```sh
$ export NETWORKX_AUTOMATIC_BACKENDS=parallel && python nx_code.py
export NETWORKX_AUTOMATIC_BACKENDS=parallel && python nx_code.py
```

Note 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:

```.py
```py
import networkx as nx
import nx_parallel as nxp

Expand All @@ -108,15 +130,19 @@ nxp.betweenness_centrality(H)

1. 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:

```.py
```py
# using `name` parameter - nx-parallel as an independent package
nxp.all_pairs_node_connectivity(H) # runs the parallel implementation in `connectivity/connectivity`
nxp.approximate_all_pairs_node_connectivity(H) # runs the parallel implementation in `approximation/connectivity`

# run the parallel implementation in `connectivity/connectivity`
nxp.all_pairs_node_connectivity(H)

# runs the parallel implementation in `approximation/connectivity`
nxp.approximate_all_pairs_node_connectivity(H)
```

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:

```.py
```py
# with subpackage - nx-parallel as a backend
nx.all_pairs_node_connectivity(H)
nx.approximation.all_pairs_node_connectivity(H)
Expand Down