Skip to content

Commit ce0996a

Browse files
committed
using vertex optimizer
1 parent 8ad5004 commit ce0996a

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/mapping.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,14 @@ function copyline_locations(tc::CopyLine; padding::Int)
336336
end
337337

338338
export ugrid
339-
function ugrid(g::SimpleGraph, vertex_order::AbstractVector{Int}; padding=2)
339+
function ugrid(g::SimpleGraph, vertex_order::AbstractVector{Int}; padding=2, nrow=nv(g))
340340
@assert padding >= 2
341341
# create an empty canvas
342342
n = nv(g)
343343
s = 4
344344
N = (n-1)*s+1+2*padding
345-
u = zeros(Int, N, N)
345+
M = nrow*s+1+2*padding
346+
u = zeros(Int, M, N)
346347

347348
# add T-copies
348349
copylines = create_copylines(g, vertex_order)
@@ -363,8 +364,9 @@ function crossat2(ug::UGrid, v, w)
363364
end
364365

365366
export embed_graph2
366-
function embed_graph2(g::SimpleGraph)
367-
ug = ugrid(g, collect(nv(g):-1:1); padding=2)
367+
function embed_graph2(g::SimpleGraph; vertex_order_optimizer=Greedy())
368+
L = pathwidth(g, vertex_order_optimizer)
369+
ug = ugrid(g, L.vertices; padding=2, nrow=L.vsep+1)
368370
for e in edges(g)
369371
I, J = crossat2(ug, e.src, e.dst)
370372
@assert ug.content[I, J-1] == 1

test/mapping.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ using Graphs, GraphTensorNetworks
3030
end
3131

3232
@testset "map configurations back" begin
33-
for graphname in [:petersen, :bull, :cubical, :house, :diamond]
33+
for graphname in [:petersen, :bull, :cubical, :house, :diamond, :tutte]
3434
@show graphname
3535
g = smallgraph(graphname)
3636
ug = embed_graph2(g)

0 commit comments

Comments
 (0)