-
Notifications
You must be signed in to change notification settings - Fork 46
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
Add Tarjan and Lengauer's (almost) linear time dominators algorithm #336
Conversation
8ab7165
to
47d9f2a
Compare
47d9f2a
to
1f1b2ad
Compare
The following things still need to be done (hoops to be jumped through):
Also we might consider:
|
c50eb49
to
ecbc9ae
Compare
dcda57b
to
db33f03
Compare
Codecov Report
@@ Coverage Diff @@
## master #336 +/- ##
==========================================
+ Coverage 96.96% 97.01% +0.04%
==========================================
Files 45 45
Lines 12542 12881 +339
==========================================
+ Hits 12161 12496 +335
- Misses 381 385 +4
|
There are still a couple of things to do in this PR, so no need for review just yet. |
Thanks @james-d-mitchell! Let me know if there's anything I could do! |
@marinaanagno when you have a moment, can you please review this PR? Once you've done that I'll squash the commits into one again (I left them separate for the time being so that you can see what I did today), and add you and Sam as co-authors for the commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code seems to agree with the theory stated in the paper and seems to be giving right results. Since this is a project I've been involved though and since I am a newcomer a quick look from another pair of eyes would be great! My only comment is on the complexity, but again it is very possible that I might be missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good, I only suggested a change in the phrasing in the complexity part of the documentation
Thanks @marinaanagno much appreciated. I wonder if the wording about the complexity in the manual entry for |
@james-d-mitchell you're absolutely right! Sorry I didn't annotate that! |
3cbfb33
to
accd1bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, it occurred to me after I had a look. Compress
is a recursive function and I'm afraid we've said that we have to make it non-recursive before merging.
Good point! I’ll have to fix this, maybe not today though 😎 |
After discussing this issue with @james-d-mitchell we figured out that compress will only run log2 of the number of vertices and no digraph that can be calculated using GAP will hit the recursion limit for compress |
Something that reviewers should have in mind while reviewing: what should the return value be? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @marinaanagno and @samanthaharper for your work on this! I've looked at it for quite a while, including reading parts of the paper (although I don't have the time to read the whole thing).
I see that you've followed the pseudocode of the paper quite closely, so I'm pretty much happy to believe that you've done that correctly (having checked a few bits myself) 🙂. The number of tests give me confidence that you have.
My one slight concern about the code is the following. At points, the paper defines things in terms of the vertices less than another vertex (i.e. 5 < 7
). Seeing as you're most familiar with the code, I would just like you to convince yourselves that you are not relying on either the list of out-neighbours or the list of in-neighbours of a vertex being sorted. Because they aren't guaranteed to be sorted (although in-neighbours usually are sorted into ascending order).
Some quick testing indicates this isn't an issue, but I'd appreciate it if you could think about it.
I've 'requested changes' for my suggestions on the documentation.
As for the question 'what should the function return' which @james-d-mitchell brought up on the call today, I now understand that to mean 'should DominatorsTree
exist as a user-facing function'? And I don't particularly mind about this either way. But if you keep it, I'm happy for it to return a record as it currently does (just please document what those things mean, mathematically 🙂 ).
Thank you so much for the review @wilfwilson, I will look carefully at all the changes you suggested probably tomorrow :) |
e66df3f
to
808baf1
Compare
@wilfwilson @marinaanagno @samanthaharper I think this is good to go, except possibly: I'm not sure if we ever arrived at a decision about whether or not a vertex should dominate itself, any thoughts? |
@james-d-mitchell thanks for this! According to the theory a vertex is not dominated by itself and if there's no reason to include it in the list of dominators, I would suggest we make the algorithm agree with the theory. :) |
That was my feeling too. |
808baf1
to
ffc9ed8
Compare
Co-authored-by: Marina Anagnostopoulou-Merkouri <mam49@st-andrews.ac.uk> Co-authored-by: Samantha Harper <seh25@st-andrews.ac.uk>
ffc9ed8
to
4653ec2
Compare
Thanks @marinaanagno and @wilfwilson I've updated the PR to not include a vertex as a dominator of itself (I think). The only other thing that I think was pending was whether or not |
@james-d-mitchell looks good to me! As far as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I've just updated this with the master branch; I'll merge if the CI passes again (which it should!).
Thanks so much @wilfwilson ! :) |
This work in progress