Another interesting representation often used by algorithms is the
adjacency lists representation.
It uses three row vectors, lp,
ls and la. If n is the number of nodes and m is the number
of arcs of the graph:
lp is the pointer array (size = n+1)
ls is the node array (size = m)
la is the arc array (size = m).
If the graph is undirected, each edge corresponds to two arcs.
With this type of representation, it is easy to know the successors of a node. Node number i has lp(i+1)-lp(i) successors nodes with numbers from ls(lp(i)) to ls(lp(i+1)-1), the corresponding arcs are have numbers from la(lp(i)) to la(lp(i+1)-1).
The adjacency lists representation of the graph of figure 1 is given below:
The function used to compute the adjacency list representation of a graph is adj_lists.