Fix bugs in Graph struct