@@ -603,12 +603,13 @@ function gauge_edge(
603
603
# # TODO : Implement as `only(common_neighbors(tn, src(edge), dst(edge)))`
604
604
# new_vertex = only(neighbors(tn, src(edge)) ∩ neighbors(tn, dst(edge)))
605
605
# return contract(tn, new_vertex => dst(edge))
606
+ ! has_edge (tn, edge) && throw (ArgumentError (" Edge not in graph." ))
606
607
tn = copy (tn)
607
608
left_inds = uniqueinds (tn, edge)
608
609
ltags = tags (tn, edge)
609
610
X, Y = factorize (tn[src (edge)], left_inds; tags= ltags, ortho= " left" , kwargs... )
610
- tn[src (edge)] = X
611
- tn[dst (edge)] *= Y
611
+ @preserve_graph tn[src (edge)] = X
612
+ @preserve_graph tn[dst (edge)] = tn[ dst (edge)] * Y
612
613
return tn
613
614
end
614
615
@@ -677,12 +678,13 @@ end
677
678
678
679
# TODO : decide whether to use graph mutating methods when resulting graph is unchanged?
679
680
function _truncate_edge (tn:: AbstractITensorNetwork , edge:: AbstractEdge ; kwargs... )
681
+ ! has_edge (tn, edge) && throw (ArgumentError (" Edge not in graph." ))
680
682
tn = copy (tn)
681
683
left_inds = uniqueinds (tn, edge)
682
684
ltags = tags (tn, edge)
683
685
U, S, V = svd (tn[src (edge)], left_inds; lefttags= ltags, kwargs... )
684
- tn[src (edge)] = U
685
- tn[dst (edge)] *= (S * V)
686
+ @preserve_graph tn[src (edge)] = U
687
+ @preserve_graph tn[dst (edge)] = tn[ dst (edge)] * (S * V)
686
688
return tn
687
689
end
688
690
0 commit comments