Skip to content

Commit

Permalink
Test k_truss
Browse files Browse the repository at this point in the history
  • Loading branch information
eriknw committed Oct 31, 2023
1 parent a056b57 commit 137bad9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
4 changes: 4 additions & 0 deletions python/nx-cugraph/_nx_cugraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
# BEGIN: extra_docstrings
"betweenness_centrality": "`weight` parameter is not yet supported.",
"edge_betweenness_centrality": "`weight` parameter is not yet supported.",
"k_truss": (
"Currently raises `NotImplementedError` for graphs with more than one connected\n"
"component when k >= 3. We expect to fix this soon."
),
"louvain_communities": "`seed` parameter is currently ignored.",
# END: extra_docstrings
},
Expand Down
30 changes: 30 additions & 0 deletions python/nx-cugraph/nx_cugraph/tests/test_ktruss.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (c) 2023, NVIDIA CORPORATION.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import networkx as nx
import pytest

import nx_cugraph as nxcg


@pytest.mark.parametrize(
"get_graph", [nx.florentine_families_graph, nx.les_miserables_graph]
)
def test_k_truss(get_graph):
Gnx = get_graph()
Gcg = nxcg.from_networkx(Gnx, preserve_all_attrs=True)
for k in range(10):
Hnx = nx.k_truss(Gnx, k)
Hcg = nxcg.k_truss(Gcg, k)
assert nx.utils.graphs_equal(Hnx, nxcg.to_networkx(Hcg))
if Hnx.number_of_edges() == 0:
break
5 changes: 4 additions & 1 deletion python/nx-cugraph/nx_cugraph/utils/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from __future__ import annotations

from functools import partial, update_wrapper
from textwrap import dedent

from networkx.utils.decorators import nodes_or_number, not_implemented_for

Expand Down Expand Up @@ -65,7 +66,9 @@ def __new__(
)
instance.extra_params = extra_params
# The docstring on our function is added to the NetworkX docstring.
instance.extra_doc = func.__doc__
instance.extra_doc = (
dedent(func.__doc__.lstrip("\n").rstrip()) if func.__doc__ else None
)
# Copy __doc__ from NetworkX
if instance.name in _registered_algorithms:
instance.__doc__ = _registered_algorithms[instance.name].__doc__
Expand Down

0 comments on commit 137bad9

Please sign in to comment.