calculate min cuts for undirected graph