From 3ae9b12f2391fdbb06f16399aae3c657ebb2f2cf Mon Sep 17 00:00:00 2001 From: Joseph Tindall <51231103+JoeyT1994@users.noreply.github.com> Date: Thu, 13 Jul 2023 15:33:59 -0400 Subject: [PATCH] Better Edge Tag Naming (#102) --- src/indextags.jl | 12 ++---------- src/sitetype.jl | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/indextags.jl b/src/indextags.jl index 88790c36..1ca3fdf1 100644 --- a/src/indextags.jl +++ b/src/indextags.jl @@ -1,18 +1,10 @@ # Helper functions -vertex_tag(v) = "$v" - -function vertex_tag(v::Tuple) - t = "$(vertex_tag(first(v)))" - for vn in Base.tail(v) - t *= "×$(vertex_tag(vn))" - end - return t -end +vertex_tag(v) = replace("$v", "," => "×", "(" => "", ")" => "") edge_tag(e::Pair) = edge_tag(NamedEdge(e)) function edge_tag(e) - return "$(vertex_tag(src(e)))↔$(vertex_tag(dst(e)))" + return "$(vertex_tag(src(e))),$(vertex_tag(dst(e)))" end function vertex_index(v, vertex_space) diff --git a/src/sitetype.jl b/src/sitetype.jl index 6f56ef1b..a807f16b 100644 --- a/src/sitetype.jl +++ b/src/sitetype.jl @@ -3,7 +3,7 @@ function siteind(sitetype::String, v::Tuple; kwargs...) end # naming collision of ITensors.addtags and addtags keyword in siteind system -function siteind(d::Integer, v::Tuple; addtags="", kwargs...) +function siteind(d::Integer, v; addtags="", kwargs...) return ITensors.addtags( Index(d; tags="Site, $addtags", kwargs...), ITensorNetworks.vertex_tag(v) ) @@ -12,7 +12,7 @@ end function siteinds(sitetypes::AbstractDictionary, g::AbstractGraph; kwargs...) is = IndsNetwork(g) for v in vertices(g) - is[v] = [siteind(sitetypes[v], v; kwargs...)] + is[v] = [siteind(sitetypes[v], vertex_tag(v); kwargs...)] end return is end