Skip to content

Commit f18db3e

Browse files
GiggleLiu刘金国
andauthored
fix coloring - config extraction (#79)
Co-authored-by: 刘金国 <liujinguo@liujinguos-MacBook-Air.local>
1 parent a66b5d3 commit f18db3e

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/configurations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function best_solutions(gp::GraphProblem; all=false, usecuda=false, invert=false
2525
throw(ArgumentError("ConfigEnumerator can not be computed on GPU!"))
2626
end
2727
xst = generate_tensors(_x(Tropical{T}; invert), gp)
28-
ymask = trues(fill(2, length(getiyv(gp.code)))...)
28+
ymask = trues(fill(nflavor(gp), length(getiyv(gp.code)))...)
2929
if usecuda
3030
xst = togpu.(xst)
3131
ymask = togpu(ymask)

test/networks/Coloring.jl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,36 @@ end
3333
g = SimpleGraph(4)
3434
pb = Coloring{3}(g)
3535
@test solve(pb, SizeMax()) !== 4
36+
end
37+
38+
@testset "planar gadget checking" begin
39+
function graph_crossing_gadget()
40+
edges = [
41+
(1,2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 1),
42+
(9, 10), (10, 11), (11, 12), (12, 9),
43+
(1, 9), (3, 10), (5, 11), (7, 12),
44+
(2, 10), (4, 11), (6, 12), (8, 9),
45+
(13, 9), (13, 10), (13, 11), (13, 12),
46+
]
47+
g = SimpleGraph(13)
48+
for (i, j) in edges
49+
add_edge!(g, i, j)
50+
end
51+
return g
52+
end
53+
54+
g = graph_crossing_gadget()
55+
problem = Coloring{3}(g; openvertices=[3, 5])
56+
res = solve(problem, ConfigsMax())
57+
for i=1:3
58+
for ci in res[i,i].c
59+
@test ci[1] === ci[3] === ci[5] === ci[7] == i-1
60+
end
61+
end
62+
for (i, j) in [(1, 2), (1, 3), (2, 3), (2,1), (3, 1), (3, 2)]
63+
for ci in res[i,j].c
64+
@test ci[1] === ci[5] == j-1
65+
@test ci[3] === ci[7] == i-1
66+
end
67+
end
3668
end

0 commit comments

Comments
 (0)