Nonparametric Regression and Density Estimation on a Network