toTensorIndex = getToTensorIndex(contractions[i]);
if (toTensorIndex == -1 || used.get(toTensorIndex))
continue;
used.set(toTensorIndex);
positions.add(toTensorIndex);
stack.push(toTensorIndex);
}
}
return new PrimitiveSubgraph(GraphType.Graph, positions.toArray());
}