finished min cut algorithM