A data structure that stores the neighbours of node in the th index the the array.
Example

adj = [[], [2], [3, 4], [4], [1]]
If the graph is weighted, we also add weights. If the graph is undirected, we add nodes in both directions.
A data structure that stores the neighbours of node in the th index the the array.
Example

adj = [[], [2], [3, 4], [4], [1]]
If the graph is weighted, we also add weights. If the graph is undirected, we add nodes in both directions.