Simplify `projected_operator_tensors` by using `post_order_dfs_vertices`
mtfishman opened this issue · comments
In #132, the function projected_operator_tensors
is introduced to get the tensors that constitute the tree tensor network operator being projected onto a region of the network, which is then used to apply the projected operator as a map to perform algorithms like DMRG.
The ordering of the tensors determines the contraction order in contract
, but the code logic for determining the ordering is quite complicated right now. Since the projected TTNO should just be a smaller TTNO on the region of the network (including caps that are the environments/message tensors entering the region), it seems like a simpler way to write it would be to collect the tensors as a TTN with region_operator_ttn = TTN([operator(P)[s] for s in sites(P)])
and then determine the order with post_order_dfs_vertices(region_operator_ttn)
.
Even better would be to use the function contraction_sequence
and detect if the input is a TTN and then use a sequence based on post_order_dfs_vertices
, or using a specialized algorithm like 12, and then that functionality could generalize to other graph structures.