  Input-output theory is invaluable for treating superconducting and photonic
circuits connected by transmission lines or waveguides. However, this theory
cannot in general handle situations in which retro-reflections from circuit
components or configurations of beam-splitters create loops for the
traveling-wave fields that connect the systems. Here, building upon the
network-contraction theory of Gough and James [Commun. Math. Phys. 287, 1109
(2009)], we provide a compact and powerful method to treat any circuit that
contains such loops so long as the effective cavities formed by the loops are
sufficiently weak. Essentially all present-day on-chip superconducting and
photonic circuits will satisfy this weakness condition so long as the
reflectors that form the loops are not especially highly reflecting. As an
example we analyze the problem of transmitting entanglement between two qubits
connected by a transmission line with imperfect circulators, a problem for
which the new method is essential. We obtain a full solution for the optimal
receiver given that the sender employs a simple turn on/turn off. This solution
shows that near-perfect transmission is possible even with significant
retro-reflections.
