Community detection in networks by dynamical optimal transport formulation