Removed unneeded console.log() statements.
Moved  graph construction logic to buildGraph. All graph construction logic should be there.