implement the funtion of calculating difference of two graphs