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.
- number_of_isolates
- square_clustering
- local_efficiency
- closeness_vitality
- is_reachable
- tournament_is_strongly_connected
- all_pairs_node_connectivity
- approximate_all_pairs_node_connectivity
- betweenness_centrality
- node_redundancy
- all_pairs_dijkstra
- all_pairs_dijkstra_path_length
- all_pairs_dijkstra_path
- all_pairs_bellman_ford_path_length
- all_pairs_bellman_ford_path
- johnson
- all_pairs_all_shortest_paths
- all_pairs_shortest_path_length
- all_pairs_shortest_path
Script used to generate the above list
import _nx_parallel as nxp
d = nxp.get_funcs_info() # temporarily add `from .update_get_info import *` to _nx_parallel/__init__.py
for func in d:
print(f"- [{func}]({d[func]['url']})")
import networkx as nx
import nx_parallel as nxp
G = nx.path_graph(4)
H = nxp.ParallelGraph(G)
# method 1 : passing ParallelGraph object in networkx function
nx.betweenness_centrality(H)
# method 2 : using the 'backend' kwarg
nx.betweenness_centrality(G, backend="parallel")
# method 3 : using nx-parallel implementation with networkx object
nxp.betweenness_centrality(G)
# method 4 : using nx-parallel implementation with ParallelGraph object
nxp.betweenness_centrality(H)
# output : {0: 0.0, 1: 0.6666666666666666, 2: 0.6666666666666666, 3: 0.0}
-
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
andmethod 4
are not recommended. But, you can use them if you know the correctname
. For example:# 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`
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:
# with subpackage - nx-parallel as a backend nx.all_pairs_node_connectivity(H) nx.approximation.all_pairs_node_connectivity(H)
-
Right now there isn't much difference between
nx.Graph
andnxp.ParallelGraph
somethod 3
would work fine but it is not recommended because in the future that might not be the case.
Feel free to contribute to nx-parallel. You can find the contributing guidelines here. 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.
Thank you :)