Generic graph (and tree) algorithms.