finish MCMF algorithm