Conversation
|
@gdalle I have a functional function using SparseMatrixColorings
A = [
1 2 0 0 0 0 3 0 0 0
2 4 5 0 6 0 0 0 0 0
0 5 7 8 0 9 0 0 0 0
0 0 8 10 0 0 0 0 0 11
0 6 0 0 12 13 0 14 0 0
0 0 9 0 13 15 0 0 16 0
3 0 0 0 0 0 17 18 0 0
0 0 0 0 14 0 18 19 20 0
0 0 0 0 0 16 0 20 21 22
0 0 0 11 0 0 0 0 22 23
]
g = SparseMatrixColorings.Graph(A)
colors = SparseMatrixColorings.acyclic_coloring(g, SparseMatrixColorings.NaturalOrder())
@test colors == [1, 2, 1, 2, 1, 3, 2, 3, 2, 1] |
|
I checked the code in JuMP, and they use the number of edges: |
818b315 to
5f5dc01
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #36 +/- ##
==========================================
+ Coverage 99.23% 99.41% +0.18%
==========================================
Files 11 11
Lines 394 516 +122
==========================================
+ Hits 391 513 +122
Misses 3 3 ☔ View full report in Codecov by Sentry. |
|
I merged #38 even though I wanted to add a few more things so that you can rebase this PR off of it |
df82ca5 to
81bbf85
Compare
|
I merged the new |
|
I merged a few more PRs into this branch, including one that cleans up the examples from the paper figures. Interestingly, Figures 6.1 from "What" and Figure 4 from "Efficient" have the same matrix but different colorings, so it's expected that you wouldn't find both |
I remarked that but the coloring of Figure 6.1 is just an example of an acyclic coloring, it's not related to any code so I don't obtain it with my implementation. |
modified by @gdalle
acyclic_coloringwith the efficient tree-based algorithm (adds DataStructures.jl to the deps).TreeSet. It works by building a matrixTsuch thatT * upper_nonzeros(A) == vec(B)and then inverting the system.