In the permissive bfs traversal, don't allow reverse traversal #3717
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.
Just found some unintuitive traversal with the permissive BFS. For example, when there's a graph like:
When traversing from just
{b}
, the normal BFS won't allow any move since the backward traversal requires bothb
andc
. The permissive BFS, on the other hand, allows to visita
since it allows traversal whenever there's at least one node already visited.That's all I had in mind when I added the permissive BFS, but it turned out that it also visits
c
as well. The first move isb, c -> a
while allowing the missingc
, and the second move isa -> b, c
sincea
is now visited andc
is not yet visited. This doesn't seem to make sense since the reasona
is visited is because we take the backward traversal of the edge. That in turn allows the forward traversal doesn't seem to be the right thing to do.While I'm not aware of any particular impact due to this behavior, this PR prevents such traversal by checking if any of Val nodes is already marked as a previous node of an Expr node.