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

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