The graph is represented in the format as below:
MAX 12
NODE 1 1
NODE 2 2
NODE 3 3
NODE 4 4
NODE 5 5
NODE 6 6
NODE 7 7
NODE 9 9
NODE 8 8
NODE 10 10
NODE 11 11
NODE 12 12
EDGE 1 2
EDGE 2 3
EDGE 3 4
EDGE 4 5
EDGE 5 6
EDGE 6 7
EDGE 7 8
EDGE 8 9
EDGE 9 10
EDGE 10 11
EDGE 11 12
EDGE 1 12
EDGE 1 3
EDGE 1 4
EDGE 1 6
EDGE 1 8
EDGE 1 11
EDGE 1 10
EDGE 6 10
EDGE 3 6
EDGE 4 6
EDGE 5 7
EDGE 9 11
I need to use the adjacent list to read in those edges. But if I want to use it as an undirected graph, that is , ignore all the directness of all edges. How could I know the connectivity of each pair of nodes?
For example, the shortest distance between (NODE 2, NODE 8) is 2 (2->1>8) in the undirected graph, but using the Dijkstra's algorithm to this graph gets 4 (2->3->6->7->8). How could I represent the undirected graph while still using the same technique to read in edges?