Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up tests, add some minimal docs to readme #10

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
# fail-fast: true
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.10", "3.11"]
python-version: ["3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
21 changes: 2 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,12 @@

repos:
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.13.0
hooks:
- id: blacken-docs
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
files: \.(html|md|toml|yml|yaml)
args: [--prose-wrap=preserve]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.258
rev: v0.0.292
hooks:
- id: ruff
args:
- --fix
- repo: local
hooks:
- id: pyproject.toml
name: pyproject.toml
language: system
entry: python tools/generate_pyproject.toml.py
files: "pyproject.toml|requirements/.*\\.txt|tools/.*pyproject.*"
59 changes: 39 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,58 @@
## nx_parallel
## nx-parallel

A NetworkX backend plugin which uses joblib and multiprocessing for parallelization.

```python
In [1]: import networkx as nx; import nx_parallel

In [2]: G = nx.erdos_renyi_graph(10, 0.5)
In [2]: G = nx.path_graph(4)

In [3]: H = nx_parallel.ParallelGraph(G)

In [4]: nx.betweenness_centrality(H)
Out[4]:
{0: 0.0,
1: 0.0,
2: 0.0,
3: 0.0,
4: 0.0,
5: 0.0,
6: 0.0,
7: 0.0,
8: 0.0,
9: 0.0}
Out[4]: {0: 0.0, 1: 0.6666666666666666, 2: 0.6666666666666666, 3: 0.0}

```

Currently the following functions have parallelized implementations:

- centrality
- betweenness_centrality
- tournament
- is_reachable
- closeness_vitality
- efficiency_measures
- local_efficiency
```
├── centrality
│ ├── betweenness_centrality
│ ├── closeness_vitality
├── tournament
│ ├── is_reachable
├── efficiency_measures
│ ├── local_efficiency
```

![alt text](timing/heatmap_all_functions.png)

See the `/timing` folder for more heatmaps and code for heatmap generation!


### Development install

To setup a local development:

- Fork this repository.
- Clone the forked repository locally.
```
$ git clone git@github.com:<your_username>/networkx.git
```
- Create a fresh conda/mamba virtualenv and install the dependencies
```
$ pip install -e ".[developer]"
```
- Install pre-commit actions that will run the linters before making a commit
```
$ pre-commit install
```
- Make sure you can run the tests locally with
```
PYTHONPATH=. \
NETWORKX_GRAPH_CONVERT=parallel \
NETWORKX_TEST_BACKEND=parallel \
NETWORKX_FALLBACK_TO_NX=True \
pytest --pyargs networkx "$@"
```
Loading