diff --git a/README.md b/README.md index e9691fa5..e7d31bc5 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,19 @@ nx-parallel is a NetworkX backend that uses joblib for parallelization. This pro - [closeness_vitality](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/vitality.py#L9) - [is_reachable](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/tournament.py#L10) - [tournament_is_strongly_connected](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/tournament.py#L54) +- [all_pairs_node_connectivity](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/connectivity/connectivity.py#L17) +- [approximate_all_pairs_node_connectivity](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/approximation/connectivity.py#L12) - [betweenness_centrality](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/centrality/betweenness.py#L16) - [node_redundancy](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/bipartite/redundancy.py#L11) -- [all_pairs_bellman_ford_path](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/weighted.py#L16) -- [johnson](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/weighted.py#L59) +- [all_pairs_dijkstra](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/weighted.py#L28) +- [all_pairs_dijkstra_path_length](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/weighted.py#L71) +- [all_pairs_dijkstra_path](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/weighted.py#L121) +- [all_pairs_bellman_ford_path_length](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/weighted.py#L164) +- [all_pairs_bellman_ford_path](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/weighted.py#L209) +- [johnson](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/weighted.py#L252) +- [all_pairs_all_shortest_paths](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/generic.py#L10) +- [all_pairs_shortest_path_length](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/unweighted.py#L18) +- [all_pairs_shortest_path](https://github.com/networkx/nx-parallel/blob/main/nx_parallel/algorithms/shortest_paths/unweighted.py#L62)
Script used to generate the above list @@ -53,7 +62,7 @@ nxp.betweenness_centrality(H) ### Notes -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, mentioning either the full path of the implementation or the `name` parameter is recommended. For example: +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: ```.py # using full path diff --git a/nx_parallel/algorithms/approximation/connectivity.py b/nx_parallel/algorithms/approximation/connectivity.py index 8145ad01..6b7c4d9f 100644 --- a/nx_parallel/algorithms/approximation/connectivity.py +++ b/nx_parallel/algorithms/approximation/connectivity.py @@ -5,11 +5,13 @@ import nx_parallel as nxp __all__ = [ - "all_pairs_node_connectivity", + "approximate_all_pairs_node_connectivity", ] -def all_pairs_node_connectivity(G, nbunch=None, cutoff=None, get_chunks="chunks"): +def approximate_all_pairs_node_connectivity( + G, nbunch=None, cutoff=None, get_chunks="chunks" +): """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 @@ -17,6 +19,11 @@ def all_pairs_node_connectivity(G, nbunch=None, cutoff=None, get_chunks="chunks" execute these computations in parallel across all available CPU cores. At the end, the results are aggregated into a single dictionary and returned. + Note, this function uses the name `approximate_all_pairs_node_connectivity` while + dispatching to the backend in=mplementation. So, `nxp.all_pairs_node_connectivity` + will run the parallel implementation of `all_pairs_node_connectivity` present in the + `connectivity/connectivity`. Use `nxp.approximate_all_pairs_node_connectivity` instead. + Parameters ------------ get_chunks : str, function (default = "chunks") diff --git a/nx_parallel/algorithms/tournament.py b/nx_parallel/algorithms/tournament.py index eaceefa0..8452d31e 100644 --- a/nx_parallel/algorithms/tournament.py +++ b/nx_parallel/algorithms/tournament.py @@ -3,7 +3,7 @@ __all__ = [ "is_reachable", - "is_strongly_connected", + "tournament_is_strongly_connected", ] @@ -51,11 +51,15 @@ def check_closure_subset(chunk): return all(results) -def is_strongly_connected(G): +def tournament_is_strongly_connected(G): """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. + Note, this function uses the name `tournament_is_strongly_connected` while + dispatching to the backend in=mplementation. So, `nxp.tournament.is_strongly_connected` + will result in an error. Use `nxp.tournament_is_strongly_connected` instead. + networkx.tournament.is_strongly_connected : https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.tournament.is_strongly_connected.html#networkx.algorithms.tournament.is_strongly_connected """ if hasattr(G, "graph_object"): diff --git a/nx_parallel/interface.py b/nx_parallel/interface.py index 458542b3..ccef1038 100644 --- a/nx_parallel/interface.py +++ b/nx_parallel/interface.py @@ -15,10 +15,13 @@ ) from nx_parallel.algorithms.efficiency_measures import local_efficiency from nx_parallel.algorithms.isolate import number_of_isolates -from nx_parallel.algorithms import tournament +from nx_parallel.algorithms.tournament import ( + is_reachable, + tournament_is_strongly_connected, +) from nx_parallel.algorithms.vitality import closeness_vitality from nx_parallel.algorithms.approximation.connectivity import ( - all_pairs_node_connectivity, + approximate_all_pairs_node_connectivity, ) from nx_parallel.algorithms.connectivity import connectivity from nx_parallel.algorithms.cluster import square_clustering @@ -55,8 +58,8 @@ class Dispatcher: closeness_vitality = closeness_vitality # Tournament - is_reachable = tournament.is_reachable - tournament_is_strongly_connected = tournament.is_strongly_connected + is_reachable = is_reachable + tournament_is_strongly_connected = tournament_is_strongly_connected # Centrality betweenness_centrality = betweenness_centrality @@ -83,7 +86,7 @@ class Dispatcher: all_pairs_shortest_path_length = all_pairs_shortest_path_length # Approximation - approximate_all_pairs_node_connectivity = all_pairs_node_connectivity + approximate_all_pairs_node_connectivity = approximate_all_pairs_node_connectivity # Connectivity all_pairs_node_connectivity = connectivity.all_pairs_node_connectivity