Tensor network formulation of two-dimensional gravity