Learning flexible representations of stochastic processes on graphs