cg construction and modifications to graph implementation