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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.