From acb3add62e67d8357649352e81e3179416ee81ff Mon Sep 17 00:00:00 2001 From: Rick Ratzel <3039903+rlratzel@users.noreply.github.com> Date: Thu, 1 Feb 2024 18:46:22 -0600 Subject: [PATCH] Removes the `networkx_algorithm` decorator to all SCC functions to disable dispatching to them (#4120) The current cugraph `strongly_connected_components` is a legacy implementation with known issues, and in most cases should not be used until the cugraph team can provide an update. This PR removes the `networkx_algorithm` decorator from all SCC functions to disable dispatching. Users can still run the SCC functions here by accessing them directly from `nx_cugraph`: ```python >>> import nx_cugraph as nxcg >>> nxcg.strongly_connected_components(...) ``` Tested by running the `nx_cugraph` tests (`pytest nx_cugraph/tests`) and the NetworkX tests (`run_nx_tests.sh`) _Note: using the "non-breaking" label since this API was only present in nightlies and never released._ Authors: - Rick Ratzel (https://github.com/rlratzel) - Brad Rees (https://github.com/BradReesWork) Approvers: - Erik Welch (https://github.com/eriknw) URL: https://github.com/rapidsai/cugraph/pull/4120 --- python/nx-cugraph/_nx_cugraph/__init__.py | 9 +++---- .../components/strongly_connected.py | 24 ++++++++++++------- python/nx-cugraph/nx_cugraph/interface.py | 12 ++++++---- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/python/nx-cugraph/_nx_cugraph/__init__.py b/python/nx-cugraph/_nx_cugraph/__init__.py index 2f283aa153c..8b5c87a63f9 100644 --- a/python/nx-cugraph/_nx_cugraph/__init__.py +++ b/python/nx-cugraph/_nx_cugraph/__init__.py @@ -12,7 +12,11 @@ # limitations under the License. """Tell NetworkX about the cugraph backend. This file can update itself: -$ make plugin-info # Recommended method for development +$ make plugin-info + +or + +$ make all # Recommended - runs 'plugin-info' followed by 'lint' or @@ -78,7 +82,6 @@ "is_connected", "is_forest", "is_isolate", - "is_strongly_connected", "is_tree", "is_weakly_connected", "isolates", @@ -96,7 +99,6 @@ "number_connected_components", "number_of_isolates", "number_of_selfloops", - "number_strongly_connected_components", "number_weakly_connected_components", "octahedral_graph", "out_degree_centrality", @@ -111,7 +113,6 @@ "single_source_shortest_path_length", "single_target_shortest_path_length", "star_graph", - "strongly_connected_components", "tadpole_graph", "tetrahedral_graph", "transitivity", diff --git a/python/nx-cugraph/nx_cugraph/algorithms/components/strongly_connected.py b/python/nx-cugraph/nx_cugraph/algorithms/components/strongly_connected.py index d1713129703..a63b3237dfc 100644 --- a/python/nx-cugraph/nx_cugraph/algorithms/components/strongly_connected.py +++ b/python/nx-cugraph/nx_cugraph/algorithms/components/strongly_connected.py @@ -15,12 +15,7 @@ import pylibcugraph as plc from nx_cugraph.convert import _to_directed_graph -from nx_cugraph.utils import ( - _groupby, - index_dtype, - networkx_algorithm, - not_implemented_for, -) +from nx_cugraph.utils import _groupby, index_dtype, not_implemented_for __all__ = [ "number_strongly_connected_components", @@ -50,8 +45,19 @@ def _strongly_connected_components(G): return labels +# The networkx_algorithm decorator is (temporarily) removed to disable +# dispatching for this function. The current cugraph +# strongly_connected_components is a legacy implementation with known issues, +# and in most cases should not be used until the cugraph team can provide an +# update. +# +# Users can still call this via the nx_cugraph module directly: +# >>> import nx_cugraph as nxcg +# >>> nxcg.strongly_connected_components(...) + + @not_implemented_for("undirected") -@networkx_algorithm(version_added="24.02", _plc="strongly_connected_components") +# @networkx_algorithm(version_added="24.02", _plc="strongly_connected_components") def strongly_connected_components(G): G = _to_directed_graph(G) if G.src_indices.size == 0: @@ -62,7 +68,7 @@ def strongly_connected_components(G): @not_implemented_for("undirected") -@networkx_algorithm(version_added="24.02", _plc="strongly_connected_components") +# @networkx_algorithm(version_added="24.02", _plc="strongly_connected_components") def number_strongly_connected_components(G): G = _to_directed_graph(G) if G.src_indices.size == 0: @@ -72,7 +78,7 @@ def number_strongly_connected_components(G): @not_implemented_for("undirected") -@networkx_algorithm(version_added="24.02", _plc="strongly_connected_components") +# @networkx_algorithm(version_added="24.02", _plc="strongly_connected_components") def is_strongly_connected(G): G = _to_directed_graph(G) if len(G) == 0: diff --git a/python/nx-cugraph/nx_cugraph/interface.py b/python/nx-cugraph/nx_cugraph/interface.py index a57074aabb0..46ea5831b0b 100644 --- a/python/nx-cugraph/nx_cugraph/interface.py +++ b/python/nx-cugraph/nx_cugraph/interface.py @@ -69,10 +69,14 @@ def key(testpath): no_string_dtype = "string edge values not currently supported" xfail = { - key( - "test_strongly_connected.py:" - "TestStronglyConnected.test_condensation_mapping_and_members" - ): "Strongly connected groups in different iteration order", + # This is removed while strongly_connected_components() is not + # dispatchable. See algorithms/components/strongly_connected.py for + # details. + # + # key( + # "test_strongly_connected.py:" + # "TestStronglyConnected.test_condensation_mapping_and_members" + # ): "Strongly connected groups in different iteration order", } from packaging.version import parse