Algorithm For Multistage Graph