Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions examples/k23.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using UnitDiskMapping, Graphs

k23 = SimpleGraph(Edge.([1=>3, 1=>4, 1=>5, 2=>3, 2=>4, 2=>5]))

# map the graph the a diagonal-coupled unit-disk grid graph.
res = map_graph(k23)
println(res.grid_graph)
# output: a 7 x 11 DUGG
# ⋅ ● ⋅ ⋅ ⋅ ● ⋅ ⋅ ⋅ ⋅ ⋅
# ● ⋅ ● ● ● ⋅ ● ● ● ⋅ ⋅
# ⋅ ● ⋅ ⋅ ⋅ ● ⋅ ⋅ ⋅ ● ⋅
# ⋅ ● ⋅ ⋅ ⋅ ● ⋅ ⋅ ⋅ ● ⋅
# ⋅ ● ⋅ ⋅ ⋅ ● ⋅ ⋅ ⋅ ● ⋅
# ● ● ● ● ● ● ● ● ● ⋅ ●
# ⋅ ● ⋅ ⋅ ⋅ ● ⋅ ⋅ ⋅ ● ⋅

dugg = SimpleGraph(res.grid_graph)

using GenericTensorNetworks

# solve and check the MIS size
source_mis_size = solve(IndependentSet(k23), SizeMax())[]
dugg_mis_size = solve(IndependentSet(dugg), SizeMax())[]
source_mis_size.n == dugg_mis_size.n - res.mis_overhead

# map an MIS for the dugg back
dugg_mis = solve(IndependentSet(dugg), SingleConfigMax())[].c.data
source_mis = map_config_back(res, dugg_mis)
GenericTensorNetworks.is_independent_set(k23, source_mis) && count(isone, source_mis) == source_mis_size.n
9 changes: 3 additions & 6 deletions examples/petersen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ function petersen_graph()
end

g = petersen_graph()
ug = embed_graph(g)
G, tape = apply_gadgets!(copy(ug))
locs = coordinates(G)
res = map_graph(g)
G = SimpleGraph(res.grid_graph)

using GenericTensorNetworks
s1 = solve(IndependentSet(g), SizeMax())
s2 = solve(IndependentSet(SimpleGraph(G)), SizeMax())
mis_overhead0 = 2 * nv(g) * (nv(g)-1) + nv(g)
mis_overhead1 = sum(x->mis_overhead(x[1]), tape)
s1[].n == s2[].n - mis_overhead0 - mis_overhead1
s1[].n == s2[].n - res.mis_overhead
2 changes: 1 addition & 1 deletion src/mapping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function remove_order(g::AbstractGraph, vertex_order::AbstractVector{Int})
return addremove
end

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