Input Format:
V E
u1 v1 u2 v2 ... uE vE
Where V
is the number of vertices and E
is the number of edges.
The next line contains E
pairs in the form of u v
which signifies there is an edge between u
and v
UNDIRECTED:
CONNECTED:
CYCLIC:
NON BIPARTITE:
5 7
1 2 2 4 2 3 1 3 1 5 5 3 3 4
ACYCLIC:
BIPARTITE:
5 4
1 5 1 2 2 3 2 4
1 5 1 2 2 3 2 4
DISCONNECTED:
CYCLIC:
BIPARTITE:
11 10
1 2 2 4 3 5 5 6 5 10 6 7 10 9 7 8 9 8 8 11
DIRECTED:
CONNECTED:
CYCLIC:
NON BIPARTITE
5 7
1 2 2 4 3 2 3 1 1 5 4 3 5 3
The input is 1 indexed. If you want 0 index then simply subtract 1 from input. In C++ you'd do:
cin >> u >> v;
adjacencyList[u - 1].push_back(v - 1);