Learning the Markov order of paths in a network