Multistage Graph Dynamic Programming