Skip to content

Commit 253fe3f

Browse files
committed
new example k23
1 parent f9cfcc7 commit 253fe3f

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

examples/k23.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using UnitDiskMapping, Graphs
2+
3+
k23 = SimpleGraph(Edge.([1=>3, 1=>4, 1=>5, 2=>3, 2=>4, 2=>5]))
4+
5+
# map the graph the a diagonal-coupled unit-disk grid graph.
6+
res = map_graph(k23)
7+
println(res.grid_graph)
8+
# output: a 7 x 11 DUGG
9+
# ⋅ ● ⋅ ⋅ ⋅ ● ⋅ ⋅ ⋅ ⋅ ⋅
10+
# ● ⋅ ● ● ● ⋅ ● ● ● ⋅ ⋅
11+
# ⋅ ● ⋅ ⋅ ⋅ ● ⋅ ⋅ ⋅ ● ⋅
12+
# ⋅ ● ⋅ ⋅ ⋅ ● ⋅ ⋅ ⋅ ● ⋅
13+
# ⋅ ● ⋅ ⋅ ⋅ ● ⋅ ⋅ ⋅ ● ⋅
14+
# ● ● ● ● ● ● ● ● ● ⋅ ●
15+
# ⋅ ● ⋅ ⋅ ⋅ ● ⋅ ⋅ ⋅ ● ⋅
16+
17+
dugg = SimpleGraph(res.grid_graph)
18+
19+
using GenericTensorNetworks
20+
21+
# solve and check the MIS size
22+
source_mis_size = solve(IndependentSet(k23), SizeMax())[]
23+
dugg_mis_size = solve(IndependentSet(dugg), SizeMax())[]
24+
source_mis_size.n == dugg_mis_size.n - res.mis_overhead
25+
26+
# map an MIS for the dugg back
27+
dugg_mis = solve(IndependentSet(dugg), SingleConfigMax())[].c.data
28+
source_mis = map_config_back(res, dugg_mis)
29+
GenericTensorNetworks.is_independent_set(k23, source_mis) && count(isone, source_mis) == source_mis_size.n

examples/petersen.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@ function petersen_graph()
1010
end
1111

1212
g = petersen_graph()
13-
ug = embed_graph(g)
14-
G, tape = apply_gadgets!(copy(ug))
15-
locs = coordinates(G)
13+
res = map_graph(g)
14+
G = SimpleGraph(res.grid_graph)
1615

1716
using GenericTensorNetworks
1817
s1 = solve(IndependentSet(g), SizeMax())
1918
s2 = solve(IndependentSet(SimpleGraph(G)), SizeMax())
20-
mis_overhead0 = 2 * nv(g) * (nv(g)-1) + nv(g)
21-
mis_overhead1 = sum(x->mis_overhead(x[1]), tape)
22-
s1[].n == s2[].n - mis_overhead0 - mis_overhead1
19+
s1[].n == s2[].n - res.mis_overhead

src/mapping.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ function remove_order(g::AbstractGraph, vertex_order::AbstractVector{Int})
230230
return addremove
231231
end
232232

233-
function center_location(tc::CopyLine; padding::Int) where NT
233+
function center_location(tc::CopyLine; padding::Int)
234234
s = 4
235235
I = s*(tc.hslot-1)+padding+2
236236
J = s*(tc.vslot-1)+padding+1

0 commit comments

Comments
 (0)