-
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
Improve DigraphColouring #144
Improve DigraphColouring #144
Conversation
Nice. Do you think it's faster because you implemented it better, or because it's an inherently faster algorithm? I'll be happy to merge it, but I do have one request: could you update the documentation for |
Good idea I’ll do this tomorrow |
@wilfwilson on second reflection, I wonder if it might not be a good idea to have |
I support this. The remaining question would be what do we do with |
@wilfwilson I'd propose to keep |
@james-d-mitchell Sounds good! |
5fd70e8
to
cd81d70
Compare
@wilfwilson I've finished this now. I decided to go in a slightly different direction. I changed to make
and the new behaviour by doing:
Let me know if spot any issues! |
Nuts, thought I did everything |
cd81d70
to
5ca4c0a
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.
Hi @james-d-mitchell, I like this, I spotted a typo and it would be really nice if you could get test code coverage for the two lines that I pointed out.
I've changed this PR to be against master
rather than stable-0.14
, but I imagine the next release will be 0.15
, and probably fairly soon (especially if the shortest path PR is updated and merged).
@@ -202,6 +202,15 @@ function(digraph, n) | |||
"the second argument <n> must be a non-negative integer,"); | |||
fi; | |||
|
|||
if HasDigraphGreedyColouring(digraph) then | |||
if DigraphGreedyColouring(digraph) = fail then | |||
return fail; |
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.
This line is not tested by grahom.tst
SubtractBlist(available, BlistList([1 .. n], out[v])); | ||
SubtractBlist(available, BlistList([1 .. n], inn[v])); | ||
if available = empty then | ||
break; |
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.
This line is not tested by grahom.tst
doc/grahom.xml
Outdated
colouring. | ||
<P/> | ||
|
||
If <A>digraph</A> is a digraphs and <A>order</A> is a dense list consisting |
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.
Typo: is a digraphs
-> is a digraph
@@ -1301,16 +1301,16 @@ gap> gr := DigraphFromDigraph6String(Concatenation( | |||
<digraph with 45 vertices, 180 edges> | |||
gap> ChromaticNumber(gr); | |||
3 | |||
gap> DigraphColoring(gr, 3); | |||
gap> DigraphColouring(gr, 3); |
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.
Perhaps these next three tests (using Digraph(Greedy)Colouring
) should be moved to grahom.tst
, if they're executing the code from grahom.gi
.
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.
I made all of the changes you suggest @wilfwilson except this one. It looks like the tests here are designed to double check what ChromaticNumber
is doing, so I left them where they are.
This commit implements the Welsh-Powell algorithm for digraph colouring. This implementation is almost always as good as the previous one (in terms of the number of colours required), and is faster (approx. 4 times faster on DigraphRemoveLoops(RandomDigraph(10000, 0.1))).
5ca4c0a
to
30e3fb0
Compare
I just thought of something else to add to this, so please don't merge it yet. |
On second thoughts, I have nothing further to add. Merge if happy @wilfwilson |
This PR implements the Welsh-Powell algorithm for digraph colouring. This implementation is almost always as good as the previous one (in terms of the number of colours required), and is faster (approx.
4 times faster on
DigraphRemoveLoops(RandomDigraph(10000, 0.1)))
.