Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for barriers and turn restrictions in TarjanSCC #1493

Closed
wants to merge 3 commits into from

Conversation

TheMarex
Copy link
Member

This fixes missing small components.

@TheMarex
Copy link
Member Author

The Tarjan algorithm for finding strongly connected components is not compatible with turn restrictions. Counter example below:

Graph:

a----b----c
     |
     d

With an only_straight_on restriction on (a,b).

If we start the algorithm at a it will find b, add it to the stack. We continue with b which finds c but will skip d since a the turn (a, b, d) is not allowed. We continue with c which will find b and update its component index. Back to b which finds a and updates its component index. At a we have completed the component search and d is never visited, even though there is path (a, b, c, b, d) and (d, b, a) in the component.

The main problem is that we check if there is a restriction regarding (a, b, d) (th at is a restriction starting at the parent of b and using b as a via). If we would know that there is a neighbor (e.g. c) of b that belongs to the same SCC and for which the turn (c, b, d) is allowed, we could safely explore d.

There are two points in the code where we know we found an neighbor in the same SCC:

  • While we scan the edges of b, we find a neighbor that is already on the stack
  • When we get back from the recursion and update the component id of the parent (which always is a neighbor)

In each case it would cost us an additional scan of all neighbor and turn restriction lookups. The main problem is that I'm not sure if this is sufficient to find all ways.

@TheMarex
Copy link
Member Author

I added a breaking test case.

@TheMarex
Copy link
Member Author

Took another look at this, looks like we have to run TarjanSCC on the edge-expanded graph. This requires some bigger restructuring (for one we have to construct the actual DynamicGraph outside of the contractor). This might also have some ramification on the memory usage.

@TheMarex
Copy link
Member Author

Closing superseded by #1565

@TheMarex TheMarex closed this Jul 31, 2015
@TheMarex TheMarex deleted the fix/scc-with-barriers branch August 15, 2015 16:43
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.

1 participant