How it works...

We are using the adjacency list representation of the directed graph from the previous recipe, Creating an adjacency list representation of a directed graph:

Figure 10.18

The temp1 pointer is set to point to startList. That is, temp1 is pointing to the node with vertex a. If temp1 is not NULL, the node pointed to by the temp1 pointer is added to the queue. The rear variable, which is -1 at the moment, is incremented to 0 and the a node is added to the array of que nodes at index location 0. Because the value of the front index location is -1 currently, the front is also set to 0, as follows:

Figure 10.19

Thereafter, the dequeue ...

Get Practical C Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.