pub fn contract_network_along_path(
tensors: &mut HashMap<usize, Tensor>,
connections: &mut Vec<(TensorIndex, TensorIndex)>,
path: &ContractionPath,
next_id: &mut usize,
) -> QuantRS2Result<Tensor>Expand description
Contract a tensor network to a single tensor by executing the given
contraction path.
The connections list defines the bonds of the network; each bond is turned
into a shared axis label. The path gives the order of pairwise
contractions — for each step (id1, id2) the two tensors are contracted over
all axes they share (matching labels), and the merged tensor takes the place
of id1 (the same “merge into the first ID” convention produced by
calculate_greedy_contraction_path). Any tensors left uncontracted by the
path are folded together via outer products.
This performs the real contraction arithmetic via [contract_pair_multi];
it no longer returns an arbitrary existing tensor.