Closed jonbrandenburg closed 10 months ago
@jonbrandenburg Thank you! Do you have any resources or information about this tweaked approach? Where did you find it?
Maybe it would make sense to optimize StableTopologicalSort
as well. CC @jonjohnsonjr
@jonbrandenburg Thank you! Do you have any resources or information about this tweaked approach? Where did you find it?
Maybe it would make sense to optimize
StableTopologicalSort
as well. CC @jonjohnsonjr
I already updated StableTopologicalSort as well. As for resources regarding the change it came from a reading of the code. I saw the problem and decided to fix it. If you want any insight into it I'd suggest instrumenting the code (new and old) and verifying that the solutions do indeed perform within the stated bounds (original code O(V^2) and the new code O(V+E). That's how I went about confirming / verifying my assumptions / suspicions / implementation.
@jonbrandenburg
I already updated StableTopologicalSort as well.
It's still too early in the morning here in Germany, my brain hasn't reached full capacity yet :D
As for resources regarding the change it came from a reading of the code. I saw the problem and decided to fix it.
Nice job! I'm going to take a look at it.
I just pushed up a small change in the hopes that it makes the code easier to read. I have some additional changes I'd like to push that eliminate any potential concurrency issues / race conditions as well but decided to hold off on pushing them until I have a better idea which direction this PR is headed.
Fixed the TopologicalSort code to run in O(V+E) time rather than O(V^2). Can be easily confirmed by either instrumenting the code or creating larger graphs that make the time difference more obvious. Unit tests are passing.