graph and code for question 3