Skip to content

Commit 4600630

Browse files
MAINT: updated README and _nx_parallel/__init__.py (#58)
* updated readme and init * updated readme
1 parent ea8f64f commit 4600630

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

README.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,23 @@ nxp.betweenness_centrality(H)
6262

6363
### Notes
6464

65-
1. Some functions in networkx have the same name but different implementations, so to avoid these name conflicts we differentiate them by the `name` parameter in `_dispatchable` at the time of dispatching (ref. [docs](https://networkx.org/documentation/latest/reference/generated/networkx.utils.backends._dispatchable.html#dispatchable)). So, `method 4` is not recommended. Instead, mentioning either the full path of the algorithm or the `name` parameter is recommended. For example:
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:
6666

6767
```.py
68-
# using full path
69-
nx.algorithms.connectivity.connectivity.all_pairs_node_connectivity(H)
70-
nx.algorithms.approximation.connectivity.all_pairs_node_connectivity(H)
68+
# using `name` parameter - nx-parallel as an independent package
69+
nxp.all_pairs_node_connectivity(H) # runs the parallel implementation in `connectivity/connectivity`
70+
nxp.approximate_all_pairs_node_connectivity(H) # runs the parallel implementation in `approximation/connectivity`
71+
```
72+
73+
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:
7174

72-
# using `name` parameter
73-
nx.all_pairs_node_connectivity(H) # runs the parallel implementation in `connectivity/connectivity`
74-
nx.approximate_all_pairs_node_connectivity(H) # runs the parallel implementation in `approximation/connectivity`
75+
```.py
76+
# with subpackage - nx-parallel as a backend
77+
nx.all_pairs_node_connectivity(H)
78+
nx.approximation.all_pairs_node_connectivity(H)
7579
```
7680

77-
2. 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 future that might not be the case.
81+
2. 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.
7882

7983
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.
8084

_nx_parallel/__init__.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,19 @@ def get_info():
3737
"additional_docs": "The function parallelizes the calculation of two neighborhoods of vertices in `G` and checks closure conditions for each neighborhood subset in parallel.",
3838
"additional_parameters": None,
3939
},
40-
"is_strongly_connected": {
40+
"tournament_is_strongly_connected": {
4141
"url": "https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/tournament.py#L54",
4242
"additional_docs": "The parallel computation is implemented by dividing the nodes into chunks and then checking whether each node is reachable from each other node in parallel.",
4343
"additional_parameters": None,
4444
},
4545
"all_pairs_node_connectivity": {
46+
"url": "https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/connectivity/connectivity.py#L17",
47+
"additional_docs": "The parallel implementation first divides a list of all permutation (in case of directed graphs) and combinations (in case of undirected graphs) of `nbunch` into chunks and then creates a generator to lazily compute the local node connectivities for each chunk, and then employs joblib's `Parallel` function to execute these computations in parallel across all available CPU cores. At the end, the results are aggregated into a single dictionary and returned.",
48+
"additional_parameters": {
49+
'get_chunks : str, function (default = "chunks")': "A function that takes in `list(iter_func(nbunch, 2))` as input and returns an iterable `pairs_chunks`, here `iter_func` is `permutations` in case of directed graphs and `combinations` in case of undirected graphs. The default is to create chunks by slicing the list into `n` chunks, where `n` is the number of CPU cores, such that size of each chunk is atmost 10, and at least 1."
50+
},
51+
},
52+
"approximate_all_pairs_node_connectivity": {
4653
"url": "https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/approximation/connectivity.py#L12",
4754
"additional_docs": "The parallel implementation first divides the a list of all permutation (in case of directed graphs) and combinations (in case of undirected graphs) of `nbunch` into chunks and then creates a generator to lazily compute the local node connectivities for each chunk, and then employs joblib's `Parallel` function to execute these computations in parallel across all available CPU cores. At the end, the results are aggregated into a single dictionary and returned.",
4855
"additional_parameters": {
@@ -52,7 +59,9 @@ def get_info():
5259
"betweenness_centrality": {
5360
"url": "https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/centrality/betweenness.py#L16",
5461
"additional_docs": "The parallel computation is implemented by dividing the nodes into chunks and computing betweenness centrality for each chunk concurrently.",
55-
"additional_parameters": None,
62+
"additional_parameters": {
63+
'get_chunks : str, function (default = "chunks")': "A function that takes in a list of all the nodes as input and returns an iterable `node_chunks`. The default chunking is done by slicing the `nodes` into `n` chunks, where `n` is the number of CPU cores."
64+
},
5665
},
5766
"node_redundancy": {
5867
"url": "https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/bipartite/redundancy.py#L11",

0 commit comments

Comments
 (0)