Implementing an undirected graph with both lists and a matrix.