Changed type of graph to support loops.