I am given a input file that contains numbers like this:
3 (searching for value 3 in graph)
5 (number of vertices in graph)
0 0 (vertex 0 has value has value 0)
2 (add 2 edges from vertex 0)
1 ( add an edge from vertex 0 to vertex 1)
2 ( add an edge from vertex 0 to vertex 2)
1 1 (vertex 1 has value 1)
2 (add 2 edges from vertex 1)
3 (add an edge from vertex 1 to vertex 3)
4 (add an edge from vertex 1 to vertex 4)
2 2 (vertex 2 has value 2).......
I want to create an adjacency matrix using the given numbers in the file, but I am unsure of how to do this. How would I make sure I'm just filling the matrix with either 0's or 1's depending on whether or not there is an existing edge? I don't think I can just read in each file one-by-one because not all of the lines detail info about the edges. Any insight would be greatly appreciated. Thanks!