Repository navigation
Conversation
cugraph_k_core ignores its degree_type argument. When the caller
passes core_result == NULL, which core_algorithms.h documents as "call
core_number inside this function call", core numbers are computed with
an indeterminate degree type. Depending on the value, core_number
rejects it with "degree_type should be IN, OUT, or INOUT" or computes
core numbers for a degree type the caller did not request.
In cpp/src/c_api/k_core.cpp, k_core_functor::operator() declares
auto degree_type =
reinterpret_cast<cugraph::k_core_degree_type_t>(degree_type);
at line 111. The name on the right refers to the local being declared,
so the local is initialized from itself and the member degree_type_
(line 27, set in the constructor at line 42) is never read. The value
reaches cugraph::k_core as std::make_optional(degree_type) at line 119
and, when core_numbers is not given, cugraph::core_number, which checks
it in cpp/src/cores/core_number_impl.cuh lines 73-76.
cpp/src/c_api/core_number.cpp had the same defect, reported in rapidsai#4734
and fixed in rapidsai#4755; the k_core C API was not changed at that time.
Read degree_type_ instead. The member has the C enum type
cugraph_k_core_degree_type_t and the target is the unrelated C++ enum
cugraph::k_core_degree_type_t, so the conversion is a static_cast.
The C API test previously always passed a precomputed core result, so
the NULL path had no coverage. generic_k_core_test now takes the degree
type and whether to precompute core numbers, and checks the return
code of cugraph_k_core. Two new cases pass core_result == NULL:
K_CORE_DEGREE_TYPE_IN with k = 3, and K_CORE_DEGREE_TYPE_INOUT with
k = 6. On a symmetric graph INOUT core numbers are twice the IN core
numbers, so both select the same 12 edges. Using two degree types
keeps the test meaningful if the indeterminate value happens to equal
one enumerator.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
6 of 11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5714
Same self-initialization as #4734, in
k_core.cppinstead ofcore_number.cpp: the localdegree_typewas initialized from itself and the memberdegree_type_was never read. The member has the C enum typecugraph_k_core_degree_type_tand the target is the C++ enumcugraph::k_core_degree_type_t, hence astatic_cast.The C API test always precomputed core numbers, which left the
core_result == NULLpath untested.generic_k_core_testnow takes the degree type and a flag for precomputing, checks the return code ofcugraph_k_core, and has new cases withcore_result == NULLfor IN (k = 3) and INOUT (k = 6).🤖 Generated with Claude Code