Graphs can be stored in adjacency tables,
The adjacency list is n linked lists,
Linked list can be simulated with array (faster than vector).
const int N;
int h[N],e[N],ne[N],idx;// Respectively, H [i]: the head node numbered I in the figure, E [i]: the value (number) of node i, and NE [i] the IDX of the next node of node i in the linked list.
void add(int a,int b)
{
e[idx]=b;
ne[idx]=h[a];
h[a]=idx++;
}
(nodes in different linked lists can have the same value, indicating the node number. Use ne [IDX] to find the next adjacent point of the current point and H [E [IDX]] to find the adjacent point of the adjacent contact)