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
Addition of reduction rules as pre-processing of the vertex cover function #12743
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:3
Some running time examples:
|
This comment has been minimized.
This comment has been minimized.
comment:5
Removal of some trailing white spaces identified by patchbot. |
comment:6
Hellooooooooooo !!! A few comments about this patch :
All in all, a good patch Nathann |
comment:7
Replying to @nathanncohen:
I have removed the test.
Changed to list
I don't like the idea since in future improvements of the function one may need the original value of !
I'm now using the cores. Note however that what you said is not exact. When removing the neighbor of a degree one vertex from the graph, it is possible reduce the degree of some vertices to 0 or 1. These vertices are not identified by the cores function. They will thus be considered only at next iteration of the main while loop.
I was not sure of the best solution to choose when writing the function because I don't know how the neighbors function is written. I did proposed modification.
Done. I have also move some test from independent_set to vertex_cover. I have also updated the tests in the tsp function, translating sentences from french to english ;-) Thanks for your help Nathann, and congratulation for the CNRS ranking !!! |
comment:8
Hellooooooooo !!!
Totally right
+1
Oh right, you also remove neighbors... Well, at least for trees everything is removed in only one run But actually, that was the whole point of my first remark --copy/paste the code from "cores" and modify it so that this problem is solved. Its principle is actually very simple : "first compute the degree of all the vertices in your graph and keep them in a table for quick access. For as long as there is a vertex of degree 1, remove it and update the degree of its neighbors in the table." By the way there is a set method to remove an element regardless of whether it is already inside or not : set.discard
Oh my god, some tests were written in french ?
Thaaaaaaaaaaaaaaaaaaaaaaaaaanks ! Nathann |
comment:9
This new version should better fit your expectations. |
comment:10
Attachment: trac_12743_reduction_rules_for_vertex_cover.patch.gz Removal of some trailing white spaces identified by patchbot. |
comment:11
Helloooooooooooo !!! Here is what this patch does :
This being said, since your last version the "good sides" of the "cores" algorithm are used ! The list of vertices of small degree is not rebuilt n times but generated on the fly, so that only vertices whose degree has changed are checked Nathann |
comment:12
Attachment: trac_12743-review2.patch.gz Thanks for the review. Note that the file name of your review patch is incorrect. Should be trac_12743-review.patch and not trac_12734-review.patch. I don't know how to change the file name. I have corrected some mistakes in the reduction rules (some forgotten vertices). |
Attachment: trac_12743-review.patch.gz |
This comment has been minimized.
This comment has been minimized.
comment:13
Patch updated ! You were right to fix this line... In order to avoid it, I added a line to the doctests in this patch. If all is fine by you, you can set the ticket to positive review ! Nathann |
Attachment: trac_12743-doctest.patch.gz |
comment:14
All is fine for me. Thanks! |
comment:15
Arghh!!! I found a small bug: with the contraction of some vertices, we may create multi-edges, thus leading to an error since the degree is different from the size of the neighborhood. So far, my first option is instead to use a copy of the graph to make my own copy without edge labels. This is certainly not the best solution... A smarter solution is more than welcome. |
This comment has been minimized.
This comment has been minimized.
comment:16
I did the following:
This patch is now working properly but needs an extra round of review. I did some tests on large graphs (maps of the Internet by CAIDA) and the MILP algorithm returns the vertex cover in less than a minute (the graph has 36.000 nodes), but the Cliquer algorithm failed. On smaller instances (20.000 nodes), the running time of Cliquer is significantly reduced when using the reduction rules, but the improvement is unclear with the MILP. For small graphs, Cliquer is generally faster than MILP. |
comment:17
update of the patch after lots of email exchange with Nathann. I hope it is better now. |
comment:18
Well.. Sounds close to perfection I noticed only one detail : the documentation says that reduction_rules are disabled by default while it is set to True by default Nathann |
comment:19
I did the change. I also did an extra round of tests. It appears that reduction rules are especially useful when using "Cliquer" or the ILP solver "GLPK". However, it is not so clear when using CPLEX (it is sometimes even slower...). I can either let the patch as it is, or set default to False, or add a sentence like: "In some cases, it is faster to disallow reduction rules, in particular when using cplex.". |
comment:20
A sentence to explain that is may be wise or not to use the reduction rules depending on the instance would be nice indeed (both in vertex_cover and in independent_set). And of course make them enabled by default if you find that it is faster this way Nathann |
comment:21
Is this OK ? |
comment:22
Hellooooooooo David !! Well, the patch seems good to go, but there is one thing that should be changed : one of the two tests deals with randomGNP graphs, and tests the algorithms on instances of Now the problem is that this actually does not test the reductions rules :
Could you change the .3 to something like 4/50 ? It looks better this way :
So the rules are actually being tested You can set the ticket to "positive review" afterwards, for the ticket is good to go Thank for this patch ! Nathann |
comment:23
Attachment: trac_12743-combined.patch.gz Actually reduction rules were already tested with trees ;-) I have modified the RandomGNP test and all tests pass on my computer. Thank for the review. |
comment:24
Yeah yeah, but only the rule with vertices of degree 1, so...
Nathann |
comment:25
Replying to @nathanncohen:
Not necessarily since there is no correlation between the vertices in the set of vertices of degree at most 2 and the degree of the vertices. So all rules can be used. |
comment:26
Oh right ! I was thinking of the ordering given by "cores" again. Well, at least the rule that removes a vertex of degree two whose neighbors are adjacent certainly was not tested there Nathann |
Reviewer: Nathann Cohen |
Merged: sage-5.1.beta0 |
This patch does the following
This is particularly useful for sparse graphs.
More advanced reduction rules can also be considered (crown decompositions, etc.) but are not part of this patch.
APPLY:
Component: graph theory
Author: David Coudert
Reviewer: Nathann Cohen
Merged: sage-5.1.beta0
Issue created by migration from https://trac.sagemath.org/ticket/12743
The text was updated successfully, but these errors were encountered: