Added distance function to square lattice, going to implement minimum weight matching decoders using networkx.