-
Notifications
You must be signed in to change notification settings - Fork 523
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
graph/coloring: warm start optimisation of exact coloring algorithm #1705
Draft
kortschak
wants to merge
5
commits into
gonum:master
Choose a base branch
from
kortschak:graph/warm_start
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The graphs were obtained from https://mat.tepper.cmu.edu/COLOR/instances.html and converted to graph6 using the following code: package main import ( "bufio" "fmt" "os" "strconv" "strings" "gonum.org/v1/gonum/graph/encoding/graph6" "gonum.org/v1/gonum/graph/simple" ) func main() { g := simple.NewUndirectedGraph() sc := bufio.NewScanner(os.Stdin) for sc.Scan() { line := sc.Text() if len(line) == 0 || line[0] != 'e' { continue } f := strings.Fields(line) g.SetEdge(simple.Edge{F: node(f[1]), T: node(f[2])}) } fmt.Printf("%q\n", graph6.Encode(g)) } func node(s string) simple.Node { i, err := strconv.Atoi(s) if err != nil { panic(err) } return simple.Node(i) } To convert graphs (ASCII col format only), use `go run main.go < <input>.col'.
There is an optimisation that is available for the Dsatur recursive search that takes advantage of the trivial observation that the colouring of a maximum clique in the graph must be consistent with the colouring of the graph and that a maximum clique will therefore constrain the colouring of the graph. This means that if the maximum clique is first trivially coloured the search can continue from there. However, if there are multiple co-equal maximum cliques it is possible for a clique to be chosen that will force the search down a pessimal search path, so we choose the clique to start from as the clique with the least constraining effect on the rest of the graph. The optimisation has the effect of excluding large sections of the search tree with a small amount of initial work to assess the maximum cliques. This change chooses the maximum clique with the lowest degree into the rest of the graph and assigns colours to all its nodes and progresses from there.
kortschak
force-pushed
the
graph/warm_start
branch
from
August 11, 2021 03:42
57c4304
to
9f1e9d8
Compare
Codecov Report
@@ Coverage Diff @@
## master #1705 +/- ##
==========================================
+ Coverage 73.22% 73.36% +0.13%
==========================================
Files 502 511 +9
Lines 59536 60462 +926
==========================================
+ Hits 43598 44355 +757
- Misses 13487 13605 +118
- Partials 2451 2502 +51
Continue to review full report at Codecov.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DO NOT MERGE
This is here to make the optimisation public. It can be used to demonstrate the improvement in the number of recursive calls, but it not yet complete since the underlying implementation of Dsatur is quite inefficient wrt allocations. This is something that I want to improve before I complete this addition so that the comparison between the optimisation and naive implementation can be made with respect to time as well.
The optimisation is in the final two commits, the first three being from #1615.