sloppy implementation of MinCut alg