Inserted the code for graph construction