graph cut code