Skip to content

Commit

Permalink
fix coloring - config extraction (#79)
Browse files Browse the repository at this point in the history
Co-authored-by: 刘金国 <[email protected]>
  • Loading branch information
GiggleLiu and 刘金国 authored Jan 16, 2024
1 parent a66b5d3 commit f18db3e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/configurations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function best_solutions(gp::GraphProblem; all=false, usecuda=false, invert=false
throw(ArgumentError("ConfigEnumerator can not be computed on GPU!"))
end
xst = generate_tensors(_x(Tropical{T}; invert), gp)
ymask = trues(fill(2, length(getiyv(gp.code)))...)
ymask = trues(fill(nflavor(gp), length(getiyv(gp.code)))...)
if usecuda
xst = togpu.(xst)
ymask = togpu(ymask)
Expand Down
32 changes: 32 additions & 0 deletions test/networks/Coloring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,36 @@ end
g = SimpleGraph(4)
pb = Coloring{3}(g)
@test solve(pb, SizeMax()) !== 4
end

@testset "planar gadget checking" begin
function graph_crossing_gadget()
edges = [
(1,2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 1),
(9, 10), (10, 11), (11, 12), (12, 9),
(1, 9), (3, 10), (5, 11), (7, 12),
(2, 10), (4, 11), (6, 12), (8, 9),
(13, 9), (13, 10), (13, 11), (13, 12),
]
g = SimpleGraph(13)
for (i, j) in edges
add_edge!(g, i, j)
end
return g
end

g = graph_crossing_gadget()
problem = Coloring{3}(g; openvertices=[3, 5])
res = solve(problem, ConfigsMax())
for i=1:3
for ci in res[i,i].c
@test ci[1] === ci[3] === ci[5] === ci[7] == i-1
end
end
for (i, j) in [(1, 2), (1, 3), (2, 3), (2,1), (3, 1), (3, 2)]
for ci in res[i,j].c
@test ci[1] === ci[5] == j-1
@test ci[3] === ci[7] == i-1
end
end
end

0 comments on commit f18db3e

Please sign in to comment.