updated homework 2 with class for random graph