Updated code to include graph drawing