Updated the printGraph() function