created drawGraph method