Skip to content

Fix recursive-rel node filter silently ignored in SHORTEST mode (#680)#693

Open
adsharma wants to merge 1 commit into
mainfrom
fix/shortest-recursive-node-filter
Open

Fix recursive-rel node filter silently ignored in SHORTEST mode (#680)#693
adsharma wants to merge 1 commit into
mainfrom
fix/shortest-recursive-node-filter

Conversation

@adsharma

Copy link
Copy Markdown
Contributor

Fixes: #680

The node predicate on recursive relationships (e.g., (r, n | WHERE ...)) was being silently ignored when the recursive relationship uses SHORTEST mode (SHORTEST, ALL SHORTEST, WSHORTEST, ALL WSHORTEST). The filter was only checked during the output/path-reconstruction phase, not during the BFS traversal itself. This caused queries to return incorrect results that looked plausible.

Root cause: The pathNodeMask (pre-computed bitmap of nodes passing the predicate) was only used in PathsOutputWriter::checkPathNodeMask() during path construction, but was never checked in the EdgeCompute functions that drive the BFS traversal. As a result, nodes failing the predicate were still visited and used as intermediate hops, allowing the traversal to reach destinations through them.

Fix: Pass pathNodeMask from sharedState to all SHORTEST-mode EdgeCompute constructors and check the mask in each edgeCompute() call before adding a neighbor node to the next frontier (and before recording parent edges for path tracking).

Affected algorithms:

  • SingleSP (destinations & paths)
  • AllSP (destinations & paths)
  • WeightedSP (destinations & paths)
  • AllWeightedSP (paths)

@adsharma adsharma force-pushed the fix/shortest-recursive-node-filter branch from 751b366 to 3108292 Compare July 16, 2026 01:09
The node predicate on recursive relationships (e.g., `(r, n | WHERE ...)`)
was being silently ignored when the recursive relationship uses SHORTEST
mode (SHORTEST, ALL SHORTEST, WSHORTEST, ALL WSHORTEST). The filter was
only checked during the output/path-reconstruction phase, not during the
BFS traversal itself. This caused queries to return incorrect results
that looked plausible.

Root cause: The `pathNodeMask` (pre-computed bitmap of nodes passing the
predicate) was only used in `PathsOutputWriter::checkPathNodeMask()`
during path construction, but was never checked in the `EdgeCompute`
functions that drive the BFS traversal. As a result, nodes failing the
predicate were still visited and used as intermediate hops, allowing
the traversal to reach destinations through them.

Fix: Pass `pathNodeMask` from sharedState to all SHORTEST-mode
EdgeCompute constructors and check the mask in each `edgeCompute()`
call before adding a neighbor node to the next frontier (and before
recording parent edges for path tracking).

Affected algorithms:
- SingleSP (destinations & paths)
- AllSP (destinations & paths)
- WeightedSP (destinations & paths)
- AllWeightedSP (paths)
@adsharma adsharma force-pushed the fix/shortest-recursive-node-filter branch from 3108292 to 2596035 Compare July 16, 2026 01:21
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.

Recursive-rel node filter is silently ignored in SHORTEST mode (wrong results)

1 participant