The two most common ways to represent a graph is:
- An adjacency-list
- An adjacency-matrix
You have one data structure, in the initialisation phase you handle it like if it was a an adjacency-list then you try to access it as if it were an adjacency-matrix. Obviously this will never work...