  We study the problem of entanglement distribution in terms of maximizing a
utility function that captures the total fidelity of end-to-end entanglements
in a two-link linear quantum network with a source, a repeater, and a
destination. The nodes have several quantum memories, and the problem is how to
coordinate entanglement purification in each of the links, and entanglement
swapping across links, so as to achieve the goal above. We show that
entanglement swapping (i.e, deciding on the pair of qubits from each link to
perform swapping on) is equivalent to finding a max-weight matching on a
bipartite graph. Further, entanglement purification (i.e, deciding which pairs
of qubits in a link will undergo purification) is equivalent to finding a
max-weight matching on a non-bipartite graph. We propose two polynomial
algorithms, the Purify-then-Swap (PtS) and the Swap-then-Purify (StP) ones,
where the decisions about purification and swapping are taken with different
order. Numerical results show that PtS performs better than StP, and also that
the omission of purification in StP gives substantial benefits.
