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

Optimize degeneracy ordering #108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

cbowdon
Copy link

@cbowdon cbowdon commented Dec 31, 2018

I was finding loom.alg/degeneracy-ordering was running a bit slowly on a dense graph, so have had a go at speeding it up. This version calculates the updated degrees and updates the node-degree map in a single pass. I also removed an unused loop parameter and added a comment since the code is a bit more concise now.

This is the graph I was struggling with: https://gist.github.com/cbowdon/7711151498464be7a25e965497edb1c2

On my weeny laptop the version in this PR completes in 50 milliseconds whereas the original version takes at least 15 minutes (I gave up waiting) on OpenJDK 8. lein test-all still passes.

Edit: It turns out my graph had a node with an edge to itself, which was causing an infinite loop in the original implementation. After removing this edge the original version completes in 80 ms, so only a minor improvement in normal cases. Both versions return the same result.

- calculate the updated degrees and update the node-deg map in a
  single pass
- remove an unused loop parameter
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