How it works...

The user is prompted to specify the number of vertices. Assuming the user enters 5, the value of 5 will be assigned to variable n. The vertices will be automatically named 1, 2, 3, 4, and 5 for convenience. A startList pointer of the node type is defined and is set to NULL initially. The startList pointer will be pointing to the first node of the adjacency linked list that will be created from the graph.

Two structures are defined: one is called node and the other is called lst. The node structure is for making the adjacency list representation of the graph and the lst structure is for creating a minimum spanning tree. Two pointers, pq and tr, are defined of the lst type and are defined as NULL.

To make the adjacency linked ...

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.