Skip to content

fix(#6699): algo.wcc applies its relTypes filter - #6700

Merged
lvca merged 2 commits into
ArcadeData:mainfrom
ZwaarContrast:fix/algo-wcc-reltypes
Aug 24, 2026
Merged

lvca merged 2 commits into
ArcadeData:mainfrom
ZwaarContrast:fix/algo-wcc-reltypes

Conversation

@ZwaarContrast

@ZwaarContrast ZwaarContrast commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Makes algo.wcc([relTypes]) restrict the traversal to the listed edge types.

execute() now reads the argument with the existing extractRelTypes helper and passes it on,
following the pattern AlgoLeiden already uses:

  • loadGraph(db, null, relTypes, null) in place of loadGraph(db, null, null, null)
  • graph.adjacency(Vertex.DIRECTION.BOTH, relTypes) in place of the unfiltered overload

The direct executeWithCSR shortcut is now taken only for an unfiltered call.
GraphAlgorithms.connectedComponents() walks the whole view, and a provider is selected for
covering the requested edge types rather than for covering only those, so a view spanning
{A, B} satisfies a request for 'A' and the shortcut would union edges the caller asked to
leave out. A filtered call goes through loadGraph, which applies relTypes to CSR adjacency
via buildAdjacencyFromProvider, so acceleration is kept without widening the result.

Motivation

The filter did not take effect, so the result was the whole-graph answer whatever was passed,
with no error to signal it. Filtering on an edge type with no edges returned one component
containing everything, where each vertex should have been on its own.

Related issues

Fixes #6699.

For context, related relTypes work elsewhere in the package: #4287 / #4360
(algo.leiden), #6301 (algo.steinerTree), #6376 (algo.maxKCut). Separate from #6316,
which covers procedures that do not resolve a provider at all.

Checklist

  • I have run the build using mvn clean package command
  • My unit tests cover both failure and success scenarios

On the first box: the reactor runs 17,598 tests here with AlgoWCCTest at 9/0 and the
3,897-test OpenCypherTCKSuite clean, but it does not finish green in my container. Each
remaining failure was checked separately and none involve this change:
DatabaseGetSizeTest, PromQLEvaluatorIntegrationTest and
Issue6440FlushAckOnClosedDatabaseTest fail the same way on an unmodified checkout, and
WindowFunctionTest / TimeSeriesFunctionDeltaTest gave 0, 1 and 3 failures across three
identical runs of the same tree. Happy to re-run anything that would help.

Five tests added to AlgoWCCTest:

test covers
wccWithRelTypesRestrictsToThoseEdges wcc('EDGE'): {A,B,C} share an id, {D,E} share another, the two differ
wccWithRelTypesIgnoresOtherEdgeTypes wcc('OTHER'): {C,D} together, with A, B and E as three distinct singletons
wccWithUnknownRelTypeIsolatesEveryVertex wcc('NOSUCH'): five distinct ids, since that type has no edges
wccWithCommaSeparatedRelTypesCoversBoth wcc('EDGE,OTHER'): matches the unfiltered result, covering comma-separated parsing
wccWithRelTypesIsNotWidenedByAViewCoveringMoreTypes builds a view over both edge types, then checks wcc('EDGE') still separates the two components

The existing tests continue to cover the unfiltered call.

Run both ways:

with the change:     Tests run: 9, Failures: 0   BUILD SUCCESS
without the change:  Tests run: 9, Failures: 4   BUILD FAILURE

wccWithCommaSeparatedRelTypesCoversBoth passes either way, since 'EDGE,OTHER' is every edge
type in the fixture; it guards the separator handling rather than this behaviour. The other four
fail without the change.

Summary by CodeRabbit

  • New Features

    • Added relationship-type filtering to Weakly Connected Components analysis.
    • Supports filtering by one or multiple relationship types, including analytical views and mixed edge types.
    • Filtered analyses can use accelerated processing when available.
  • Bug Fixes

    • Improved component detection for graphs containing multiple relationship types.
    • Added graceful handling for unknown relationship types without affecting unfiltered analysis.

The argument was validated but never reached the traversal: execute() passed
null where the filter belongs, in both findProvider and loadGraph, so every
call returned the whole-graph answer.

Read it with the existing extractRelTypes helper and pass it through, as
AlgoLeiden already does. The direct CSR shortcut is now taken only for an
unfiltered call: connectedComponents() walks the whole view, and a provider is
selected for covering the requested edge types rather than only those, so a
view spanning {A,B} satisfies a request for 'A' and the shortcut would union
edges the caller asked to leave out. A filtered call goes through loadGraph,
which applies relTypes to CSR adjacency, keeping acceleration without widening.

Five tests in AlgoWCCTest cover the filter, an unknown type, comma-separated
types and a view covering more types than requested. Four of them fail without
the change.
@coderabbitai

coderabbitai Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5665e374-6668-4a7d-9a9a-8dcb828108a9

📥 Commits

Reviewing files that changed from the base of the PR and between 61a886f and 5f7cbe5.

📒 Files selected for processing (2)
  • engine/src/main/java/com/arcadedb/query/opencypher/procedures/algo/AlgoWCC.java
  • engine/src/test/java/com/arcadedb/query/opencypher/procedures/algo/AlgoWCCTest.java

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

algo.wcc now applies relTypes filters during CSR provider selection, CSR execution, and OLTP graph processing. Tests cover known, unknown, combined, and analytical-view relationship types.

Changes

WCC relationship-type filtering

Layer / File(s) Summary
Filter-aware WCC execution
engine/src/main/java/com/arcadedb/query/opencypher/procedures/algo/AlgoWCC.java
AlgoWCC.execute passes relationship types to CSR provider selection and connected-components execution when supported. The OLTP fallback applies the types during graph loading and adjacency construction.
Relationship-type filter tests
engine/src/test/java/com/arcadedb/query/opencypher/procedures/algo/AlgoWCCTest.java
The fixture adds the OTHER edge type. Tests verify restricted, unknown, comma-separated, analytical-view, and CSR-accelerated filtering. Helpers connect components and collect component IDs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 5f7cb

This localized change applies the requested relationship-type filter to connected-component traversal and adds focused coverage; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: lvca

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the WCC relationship-type filter fix and references issue #6699.
Description check ✅ Passed The description covers the change, motivation, related issues, testing, and additional notes with sufficient detail.
Linked Issues check ✅ Passed The implementation passes relationship-type filters through provider selection, graph loading, and adjacency construction, with regression tests for issue #6699.
Out of Scope Changes check ✅ Passed The code and test changes directly support the relationship-type filtering objectives and do not show unrelated scope.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@mergify

mergify Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@lvca
lvca self-requested a review August 24, 2026 19:16
findProvider(relTypes) already only returns a provider that covers every
requested type, and GraphAlgorithms.connectedComponents() already resolves
each requested relType to its own CSR index, so a filtered call does not
need to give up the parallel min-label propagation path for the
single-threaded OLTP BFS. Only an unfiltered call previously kept CSR
acceleration; now both do.
@lvca
lvca merged commit f59c6f2 into ArcadeData:main Aug 24, 2026
19 of 23 checks passed
@lvca

lvca commented Aug 24, 2026

Copy link
Copy Markdown
Member

Thanks @ZwaarContrast !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

algo.wcc returns the all-edges result when a relTypes filter is given

2 participants