update graph and algorithm