Allowed graph to be stored as a matrix in addition to an adjacency list