  Tensor-network codes enable the construction of large stabilizer codes out of
tensors describing smaller stabilizer codes. An application of tensor-network
codes was an efficient and exact decoder for holographic codes. Here, we show
how to write some topological codes, including the surface code and colour
code, as simple tensor-network codes. We also show how to calculate distances
of stabilizer codes by contracting a tensor network. The algorithm actually
gives more information, including a histogram of all logical coset weights. We
prove that this method is efficient in the case of holographic codes. Using our
tensor-network distance calculator, we find a modification of the rotated
surface code that has the same distance but fewer minimum-weight logical
operators by injecting the non-CSS five-qubit code tensor into the tensor
network. This corresponds to an improvement in successful error correction of
up to 2% against depolarizing noise (in the perfect-measurement setting), but
comes at the cost of introducing four higher-weight stabilizers. Our general
construction lets us pick a network geometry (e.g., a Euclidean lattice in the
case of the surface code), and, using only a small set of seed codes
(constituent tensors), build extensive codes with the potential for
optimisation.
