Skip to content

Commit

Permalink
Better Edge Tag Naming (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyT1994 authored Jul 13, 2023
1 parent 12f6f7a commit 3ae9b12
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
12 changes: 2 additions & 10 deletions src/indextags.jl
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/sitetype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand All @@ -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
Expand Down

0 comments on commit 3ae9b12

Please sign in to comment.