Skip to content

Commit 969941b

Browse files
MAINT: Added LICENSE and updated README (#59)
* Added LICENSE and updated README * some small fixes * small change * changed license * bug fix * updated testing docs * fixed docs
1 parent 4600630 commit 969941b

File tree

4 files changed

+95
-8
lines changed

4 files changed

+95
-8
lines changed

CONTRIBUTING.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ To set the local development environment:
1212
- Clone the forked repository locally.
1313

1414
```.sh
15-
git clone [email protected]:<your_username>/networkx.git
15+
git clone [email protected]:<your_username>/nx-parallel.git
1616
```
1717

1818
- Create a fresh conda/mamba virtualenv ([learn more](https://github.com/networkx/networkx/blob/main/CONTRIBUTING.rst#development-workflow))
@@ -55,7 +55,13 @@ git push origin <branch_name>
5555

5656
## Testing nx-parallel
5757

58-
The following command runs all the tests in networkx with a `ParallelGraph` object and for algorithms not in nx-parallel, it falls back to networkx's sequential implementations. This is to ensure that the parallel implementation follows the same API as networkx's.
58+
Firstly, install the dependencies for testing:
59+
60+
```.sh
61+
pip install -e ".[test]"
62+
```
63+
64+
Then run the following command that executes all the tests in networkx's test suite with a `ParallelGraph` object and for algorithms not in nx-parallel, it falls back to networkx's sequential implementations. This is to ensure that the parallel backend follows the same API as networkx's.
5965

6066
```.sh
6167
PYTHONPATH=. \
@@ -64,7 +70,9 @@ NETWORKX_FALLBACK_TO_NX=True \
6470
pytest --pyargs networkx "$@"
6571
```
6672

67-
For running additional tests:
73+
Ref. [NetworkX Backend testing docs](https://networkx.org/documentation/latest/reference/backends.html#testing-the-custom-backend) to know about testing mechanisms in networkx.
74+
75+
For running additional tests specific to nx-parallel, you can run the following command:
6876

6977
```.sh
7078
pytest nx_parallel
@@ -116,7 +124,7 @@ The default chunking in nx-parallel is done by first determining the number of a
116124
- The algorithm that you are considering to add to nx-parallel should be in the main networkx repository and it should have the `_dispatchable` decorator. If not, you can consider adding a sequential implementation in networkx first.
117125
- check-list for adding a new function:
118126
- [ ] Add the parallel implementation(make sure API doesn't break), the file structure should be the same as that in networkx.
119-
- [ ] add the function to the `Dispatcher` class in [interface.py](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/interface.py) (take care of the `name` parameter in `_dispatchable` (ref. [docs](https://networkx.org/documentation/latest/reference/generated/networkx.utils.backends._dispatchable.html#dispatchable)))
127+
- [ ] add the function to the `Dispatcher` class in [interface.py](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/interface.py) (take care of the `name` parameter in `_dispatchable` (ref. [docs](https://networkx.org/documentation/latest/reference/backends.html)))
120128
- [ ] update the `__init__.py` files accordingly
121129
- [ ] docstring following the above format
122130
- [ ] run the [timing script](https://github.com/networkx/nx-parallel/blob/main/timing/timing_individual_function.py) to get the performance heatmap

LICENSE.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2024, [Contributors of nx-parallel](https://github.com/networkx/nx-parallel/graphs/contributors)
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+50-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# nx-parallel
22

3-
nx-parallel is a NetworkX backend that uses joblib for parallelization. This project aims to provide parallelized implementations of various NetworkX functions to improve performance.
3+
nx-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.
44

55
## Algorithms in nx-parallel
66

@@ -36,16 +36,59 @@ for func in d:
3636

3737
</details>
3838

39+
## Installation
40+
41+
It is recommended to first refer the [NetworkX's INSTALL.rst](https://github.com/networkx/networkx/blob/main/INSTALL.rst).
42+
nx-parallel requires Python >=3.10. Right now, the only dependencies of nx-parallel are networkx and joblib.
43+
44+
### Install the released version
45+
46+
You can install the stable version of nx-parallel using pip:
47+
48+
```sh
49+
$ pip install nx-parallel
50+
```
51+
52+
The above command also installs the two main dependencies of nx-parallel i.e. networkx
53+
and joblib. To upgrade to a newer release use the `--upgrade` flag:
54+
55+
```sh
56+
$ pip install --upgrade nx-parallel
57+
```
58+
59+
### Install the development version
60+
61+
Before installing the development version, you may need to uninstall the
62+
standard version of `nx-parallel` and other two dependencies using `pip`:
63+
64+
```sh
65+
$ pip uninstall nx-parallel networkx joblib
66+
```
67+
68+
Then do:
69+
70+
```sh
71+
$ pip install git+https://github.com/networkx/nx-parallel.git@main
72+
```
73+
3974
## Backend usage
4075

76+
You can run your networkx code by just setting the `NETWORKX_AUTOMATIC_BACKENDS` environment variable to `parallel`:
77+
78+
```sh
79+
$ export NETWORKX_AUTOMATIC_BACKENDS=parallel && python nx_code.py
80+
```
81+
82+
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:
83+
4184
```.py
4285
import networkx as nx
4386
import nx_parallel as nxp
4487

4588
G = nx.path_graph(4)
4689
H = nxp.ParallelGraph(G)
4790

48-
# method 1 : passing ParallelGraph object in networkx function
91+
# method 1 : passing ParallelGraph object in networkx function (Type-based dispatching)
4992
nx.betweenness_centrality(H)
5093

5194
# method 2 : using the 'backend' kwarg
@@ -62,7 +105,7 @@ nxp.betweenness_centrality(H)
62105

63106
### Notes
64107

65-
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`](https://networkx.org/documentation/latest/reference/generated/networkx.utils.backends._dispatchable.html#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:
108+
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:
66109

67110
```.py
68111
# using `name` parameter - nx-parallel as an independent package
@@ -82,4 +125,8 @@ nxp.betweenness_centrality(H)
82125

83126
Feel free to contribute to nx-parallel. You can find the contributing guidelines [here](https://github.com/networkx/nx-parallel/blob/main/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.
84127

128+
This 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.
129+
130+
All code in this repository is available under the Berkeley Software Distribution (BSD) 3-Clause License (see LICENSE).
131+
85132
Thank you :)

pyproject.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ path = "nx_parallel/__init__.py"
2727
[project.optional-dependencies]
2828
developer = [
2929
'pre-commit',
30-
'pytest',
30+
]
31+
test = [
32+
'pytest>=7.2',
33+
'numpy>=1.23',
34+
'scipy>=1.9,!=1.11.0,!=1.11.1',
3135
]
3236

3337
[project.entry-points."networkx.backends"]

0 commit comments

Comments
 (0)