Align RXFilter edge query semantics with SQLFilter#314
Merged
Conversation
The rustworkx backend's filter returned wrong edges in two ways:
1. With include_sources=True, an edge whose endpoints were both
selected was visited twice (out_edges of its source and in_edges of
its target) and returned duplicated.
2. Endpoint membership was only enforced when explicit node_ids were
given AND no include flag was set. Edges leaving the selected set
leaked into the result for attribute-filtered queries (e.g.
filter(NodeAttr('t') == 1).edge_attrs() returned edges into t == 2)
and whenever include_sources/include_targets was set. This also made
filter(...).edge_attrs() disagree with filter(...).subgraph() and
with the SQL backend.
Deduplicate visited edges and enforce SQLFilter's rule: the source must
be in the selected set unless include_sources, the target unless
include_targets.
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.
Two defects in the rustworkx filter's edge queries:
include_sources=True, edges with both endpoints selected were returned twice (visited via bothout_edgesandin_edges).node_idsand no include flags, so edges leaked outside the selection — e.g.filter(NodeAttr("t") == 1).edge_attrs()returned edges intot == 2, disagreeing with SQLGraph and with the same filter'ssubgraph().Deduplicate visited edges and enforce SQLFilter's rule: source must be selected unless
include_sources, target unlessinclude_targets.Added a backend-parametrized regression test.