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

Quadratic Time Complexity #1

Open
ekzhang opened this issue Dec 21, 2017 · 1 comment
Open

Quadratic Time Complexity #1

ekzhang opened this issue Dec 21, 2017 · 1 comment

Comments

@ekzhang
Copy link

ekzhang commented Dec 21, 2017

On line 53 of StronglyConnectedComponentFinder, the Stack.Contains method is being used, which runs in O(V) time, which is a bottleneck for the algorithm that can cause it to run in worst-case O(V^2) time. This small bug unfortunately renders the implementation useless, as it can be superseded easily by a naive solution.

@danielrbradley Could you modify the code to use, for example, an array of boolean flags to see if the vertex is in the stack or not? This would fix the bug and make the algorithm run in linear time as expected. Sorry that I am not able to make this change myself; I do not have enough experience working with C#.

@danielrbradley
Copy link
Owner

Thanks for the suggestion. I'm not actively maintaining this project (haven't opened it in 5 years now), but am happy to merge any PRs if someone wants to take a stab at it 🙂

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

No branches or pull requests

2 participants