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

Improve performance of topological sort #79

Merged
merged 1 commit into from Mar 27, 2020

Conversation

dabbott
Copy link
Contributor

@dabbott dabbott commented Mar 27, 2020

This change improves the performance of topological sort by removing the linear lookups of vertices. I think it was something like O(n^4) with calls to indexOfVertex. I also try to do fewer vertex allocations by using indices everywhere, although this is relatively minor in comparison.

I didn't test exhaustively, but in my use case with ~500 vertices and ~500 edges, sorting went from 12s to 20ms!

@davecom
Copy link
Owner

davecom commented Mar 27, 2020

Thanks, @dabbott . This is an awesome and straightforward fix!

@davecom davecom merged commit 1e1f999 into davecom:master Mar 27, 2020
@dabbott dabbott deleted the improve-topo-sort-perf branch March 27, 2020 23:23
@kokluch
Copy link

kokluch commented Feb 19, 2021

Hi @dabbott, is there a coming tag including this enhancement? We've tried it and it's significantly faster. We'd like to integrate it in production code.

@davecom
Copy link
Owner

davecom commented Feb 19, 2021

Hi @kokluch,
I’ll push out a 3.0.1 version late today including @dabbott’s performance improvement. Thanks for using SwiftGraph.

@davecom
Copy link
Owner

davecom commented Feb 20, 2021

Hi @kokluch,
This ended up getting pushed as 3.1. It's live now. Out of curiosity, what app are you using SwiftGraph in?
Thanks,
David

@kokluch
Copy link

kokluch commented Feb 22, 2021

Hi @davecom,
Thanks for the tag :) however it's not a valid spm format so I cannot retrieve it properly. Would you be kind to make it 3.1.0? I would really appreciate.
As for the apps I can't say much but you'll find SwiftGraph license mentioned on the followed apps:
https://apps.apple.com/fr/app/netatmo-security/id951725393
https://apps.apple.com/fr/app/netatmo-weather/id532538499
https://apps.apple.com/fr/app/home-control/id1188809809
This list is not exhaustive.

@davecom
Copy link
Owner

davecom commented Feb 23, 2021

Hi @kokluch,

Oops, sorry about that. I just pushed a 3.1.0 tag, hopefully that fixes the issue. And thanks for the info, that's very encouraging to know.

Best,
David

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.

None yet

3 participants