graph cut material .pdf file. you can take it as reference. it will be good to you.