Question: C or C++ Graph in Adjacency Format: (Code Must compile and run in GCC) Input to the program is an undirected graph in adjacency list
C or C++ Graph in Adjacency Format: (Code Must compile and run in GCC) Input to the program is an undirected graph in adjacency list format. To store the graph, you should set up an array G, so that G[i]) is a pointer to a linked list storing vertices adjacent to vertex i. Your program must output the degrees of vertices in the sorted order. You must use bucket sorting for sorting degrees, and have an array Bucket of pointers in your program so that Bucket[i] points to a linked list containing all vertices that have degree i. You should not use STL for this assignment.
Program should read from a file called data2.txt and write to file called out2.txt. Input file will contain multiple data sets, separated by one blank line. Your program must output the sorted degrees of each graph.Your program must work on graphs of up to 1000 vertices.
Input example:
12 21 3 32 // meaning node 1 is connected to node 2 and node 3
12 3 21 3 32 1 // meaning node 2 is connected to node 1 and node 3
12 21 34 43 //meaning node 3 is connected to node 2 and node 1
Output example:
Sorted degrees for graph one are:1,1,2
Sorted degrees for graph two are:2,2,2
Sorted degrees for graph three are:1,1,1,1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
