@@ -11,13 +11,13 @@ using NamedGraphs.GraphsExtensions: directed_graph, incident_edges, rem_edges!,
1111using NamedGraphs. OrdinalIndexing: OrdinalSuffixedInteger
1212using NamedGraphs: NamedGraphs, NamedGraph, not_implemented, similar_graph
1313
14- abstract type AbstractTensorNetwork {V, VD} <: AbstractDataGraph{V, VD, Nothing} end
14+ abstract type AbstractITensorNetwork {V, VD} <: AbstractDataGraph{V, VD, Nothing} end
1515
1616# Need to be careful about removing edges from tensor networks in case there is a bond
17- Graphs. rem_edge! (:: AbstractTensorNetwork , edge) = not_implemented ()
17+ Graphs. rem_edge! (:: AbstractITensorNetwork , edge) = not_implemented ()
1818
1919# Graphs.jl overloads
20- function Graphs. weights (graph:: AbstractTensorNetwork )
20+ function Graphs. weights (graph:: AbstractITensorNetwork )
2121 V = vertextype (graph)
2222 es = Tuple .(edges (graph))
2323 ws = Dictionary {Tuple{V, V}, Float64} (es, undef)
@@ -29,28 +29,28 @@ function Graphs.weights(graph::AbstractTensorNetwork)
2929end
3030
3131# Copy
32- Base. copy (:: AbstractTensorNetwork ) = not_implemented ()
32+ Base. copy (:: AbstractITensorNetwork ) = not_implemented ()
3333
3434# Iteration
35- Base. iterate (tn:: AbstractTensorNetwork , args... ) = iterate (vertex_data (tn), args... )
36- Base. keys (tn:: AbstractTensorNetwork ) = vertices (tn)
35+ Base. iterate (tn:: AbstractITensorNetwork , args... ) = iterate (vertex_data (tn), args... )
36+ Base. keys (tn:: AbstractITensorNetwork ) = vertices (tn)
3737
3838# TODO : This contrasts with the `DataGraphs.AbstractDataGraph` definition,
3939# where it is defined as the `vertextype`. Does that cause problems or should it be changed?
40- Base. eltype (tn:: AbstractTensorNetwork ) = eltype (vertex_data (tn))
40+ Base. eltype (tn:: AbstractITensorNetwork ) = eltype (vertex_data (tn))
4141
4242# Overload if needed
43- Graphs. is_directed (:: Type{<:AbstractTensorNetwork } ) = false
43+ Graphs. is_directed (:: Type{<:AbstractITensorNetwork } ) = false
4444
45- DataGraphs. underlying_graph (:: AbstractTensorNetwork ) = not_implemented ()
46- function NamedGraphs. vertex_positions (tn:: AbstractTensorNetwork )
45+ DataGraphs. underlying_graph (:: AbstractITensorNetwork ) = not_implemented ()
46+ function NamedGraphs. vertex_positions (tn:: AbstractITensorNetwork )
4747 return NamedGraphs. vertex_positions (underlying_graph (tn))
4848end
49- function NamedGraphs. ordered_vertices (tn:: AbstractTensorNetwork )
49+ function NamedGraphs. ordered_vertices (tn:: AbstractITensorNetwork )
5050 return NamedGraphs. ordered_vertices (underlying_graph (tn))
5151end
5252
53- function Adapt. adapt_structure (to, tn:: AbstractTensorNetwork )
53+ function Adapt. adapt_structure (to, tn:: AbstractITensorNetwork )
5454 # TODO : Define and use:
5555 #
5656 # @preserve_graph map_vertex_data(adapt(to), tn)
@@ -135,14 +135,14 @@ macro preserve_graph(expr)
135135 return :(setindex_preserve_graph! ($ (esc (array)), $ (esc (value)), $ (esc .(indices)... )))
136136end
137137
138- # Update the graph of the TensorNetwork `tn` to include
138+ # Update the graph of the ITensorNetwork `tn` to include
139139# edges that should exist based on the tensor connectivity.
140140function add_missing_edges! (tn:: AbstractGraph )
141141 foreach (v -> add_missing_edges! (tn, v), vertices (tn))
142142 return tn
143143end
144144
145- # Update the graph of the TensorNetwork `tn` to include
145+ # Update the graph of the ITensorNetwork `tn` to include
146146# edges that should be incident to the vertex `v`
147147# based on the tensor connectivity.
148148function add_missing_edges! (tn:: AbstractGraph , v)
@@ -157,13 +157,13 @@ function add_missing_edges!(tn::AbstractGraph, v)
157157 return tn
158158end
159159
160- # Fix the edges of the TensorNetwork `tn` to match
160+ # Fix the edges of the ITensorNetwork `tn` to match
161161# the tensor connectivity.
162162function fix_edges! (tn:: AbstractGraph )
163163 foreach (v -> fix_edges! (tn, v), vertices (tn))
164164 return tn
165165end
166- # Fix the edges of the TensorNetwork `tn` to match
166+ # Fix the edges of the ITensorNetwork `tn` to match
167167# the tensor connectivity at vertex `v`.
168168function fix_edges! (tn:: AbstractGraph , v)
169169 for e in incident_edges (tn, v)
@@ -176,12 +176,12 @@ function fix_edges!(tn::AbstractGraph, v)
176176 return tn
177177end
178178
179- using ITensorBase: denamedtype, named, nametype, uniquename
179+ using ITensorBase: named, nametype, uniquename, unnamedtype
180180using TensorAlgebra: trivialrange
181181function insertlink! (tn, e)
182182 add_edge! (tn, e)
183183 T = eltype (inds (tn[src (e)]))
184- l = named (trivialrange (denamedtype (T)), uniquename (nametype (T)))
184+ l = named (trivialrange (unnamedtype (T)), uniquename (nametype (T)))
185185 x = fill! (similar (tn[src (e)], (l,)), one (eltype (tn[src (e)])))
186186 @preserve_graph tn[src (e)] = tn[src (e)] * x
187187 @preserve_graph tn[dst (e)] = tn[dst (e)] * conj (x)
@@ -202,28 +202,32 @@ function randlinknames(tn)
202202 return new_tn
203203end
204204
205- function Base. setindex! (tn:: AbstractTensorNetwork , value, v)
205+ function Base. setindex! (tn:: AbstractITensorNetwork , value, v)
206206 @preserve_graph tn[v] = value
207207 fix_edges! (tn, v)
208208 return tn
209209end
210210# Fix ambiguity error.
211- function Base. setindex! (graph:: AbstractTensorNetwork , value, vertex:: OrdinalSuffixedInteger )
211+ function Base. setindex! (
212+ graph:: AbstractITensorNetwork ,
213+ value,
214+ vertex:: OrdinalSuffixedInteger
215+ )
212216 graph[vertices (graph)[vertex]] = value
213217 return graph
214218end
215- Base. setindex! (tn:: AbstractTensorNetwork , value, edge:: AbstractEdge ) = not_implemented ()
216- Base. setindex! (tn:: AbstractTensorNetwork , value, edge:: Pair ) = not_implemented ()
219+ Base. setindex! (tn:: AbstractITensorNetwork , value, edge:: AbstractEdge ) = not_implemented ()
220+ Base. setindex! (tn:: AbstractITensorNetwork , value, edge:: Pair ) = not_implemented ()
217221# Fix ambiguity error.
218222function Base. setindex! (
219- tn:: AbstractTensorNetwork ,
223+ tn:: AbstractITensorNetwork ,
220224 value,
221225 edge:: Pair{<:OrdinalSuffixedInteger, <:OrdinalSuffixedInteger}
222226 )
223227 return not_implemented ()
224228end
225229
226- function Base. show (io:: IO , mime:: MIME"text/plain" , graph:: AbstractTensorNetwork )
230+ function Base. show (io:: IO , mime:: MIME"text/plain" , graph:: AbstractITensorNetwork )
227231 println (io, " $(typeof (graph)) with $(nv (graph)) vertices:" )
228232 show (io, mime, vertices (graph))
229233 println (io, " \n " )
@@ -238,4 +242,4 @@ function Base.show(io::IO, mime::MIME"text/plain", graph::AbstractTensorNetwork)
238242 return nothing
239243end
240244
241- Base. show (io:: IO , graph:: AbstractTensorNetwork ) = show (io, MIME " text/plain" (), graph)
245+ Base. show (io:: IO , graph:: AbstractITensorNetwork ) = show (io, MIME " text/plain" (), graph)
0 commit comments