Skip to content

Commit

Permalink
Add note to k-truss and skip very slow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eriknw committed Oct 31, 2023
1 parent 447cdfd commit c5350c2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
14 changes: 9 additions & 5 deletions python/nx-cugraph/nx_cugraph/algorithms/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,17 @@
@not_implemented_for("multigraph")
@networkx_algorithm
def k_truss(G, k):
"""
Currently raises `NotImplementedError` for graphs with more than one connected
component when k >= 3. We expect to fix this soon.
"""
if is_nx := isinstance(G, nx.Graph):
G = nxcg.from_networkx(G, preserve_all_attrs=True)
if nxcg.number_of_selfloops(G) > 0:
raise nx.NetworkXError(
"Input graph has self loops which is not permitted; "
"Consider using G.remove_edges_from(nx.selfloop_edges(G))."
)
if (ncc := nxcg.number_connected_components(G)) > 1:
raise NotImplementedError(
"nx_cugraph.k_truss does not yet work on graphs with more than one "
f"connected component (this graph has {ncc}). We expect to fix this soon."
)

# TODO: create renumbering helper function(s)
if k < 3:
Expand All @@ -56,6 +55,11 @@ def k_truss(G, k):
# Renumber step 1: edge values (no changes needed)
edge_values = {key: val.copy() for key, val in G.edge_values.items()}
edge_masks = {key: val.copy() for key, val in G.edge_masks.items()}
elif (ncc := nxcg.number_connected_components(G)) > 1:
raise NotImplementedError(
"nx_cugraph.k_truss does not yet work on graphs with more than one "
f"connected component (this graph has {ncc}). We expect to fix this soon."
)
else:
# int dtype for edge_indices would be preferred
edge_indices = cp.arange(G.src_indices.size, dtype=np.float64)
Expand Down
9 changes: 9 additions & 0 deletions python/nx-cugraph/nx_cugraph/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,20 @@ def key(testpath):
key("test_louvain.py:test_threshold")
] = "Louvain does not support seed parameter"

too_slow = "Too slow to run"
skip = {
key("test_tree_isomorphism.py:test_positive"): too_slow,
key("test_tree_isomorphism.py:test_negative"): too_slow,
}

for item in items:
kset = set(item.keywords)
for (test_name, keywords), reason in xfail.items():
if item.name == test_name and keywords.issubset(kset):
item.add_marker(pytest.mark.xfail(reason=reason))
for (test_name, keywords), reason in skip.items():
if item.name == test_name and keywords.issubset(kset):
item.add_marker(pytest.mark.skip(reason=reason))

@classmethod
def can_run(cls, name, args, kwargs):
Expand Down
1 change: 1 addition & 0 deletions python/nx-cugraph/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ ignore = [
# Allow assert, print, RNG, and no docstring
"nx_cugraph/**/tests/*py" = ["S101", "S311", "T201", "D103", "D100"]
"_nx_cugraph/__init__.py" = ["E501"]
"nx_cugraph/algorithms/**/*py" = ["D205", "D401"] # Allow flexible docstrings for algorithms

[tool.ruff.flake8-annotations]
mypy-init-return = true
Expand Down

0 comments on commit c5350c2

Please sign in to comment.