add final graph cut code