When you compare the preceding program with that of the directed graph, you will notice that only one extra statement has been added (marked in bold):
edg[v2][v1]=1;
That is, in the case of an edge from v1 to v2, an edge in reverse is also assumed, that is, from v2 to v1.
The program is compiled using GCC, as shown in the following screenshot. Because no error appears during the compilation, this means the adjmatundirect.c program has successfully compiled into the adjmatundirect.exe file. As expected, on running the file, the user will be prompted to specify the number of vertices and their edges. Once the number of vertices and edges are entered, the program will display the adjacency matrix representation of the undirected graph, as shown in the following screenshot:
Now, let's move on to the next recipe!