Question: NEED SOME HELP WITH GRAPHS. create a C++ program that receives in input a weighted graph and groups its nodes in the required number of
NEED SOME HELP WITH GRAPHS.
create a C++ program that receives in input a weighted graph and groups its nodes in the required number of clusters. Input and Output The input is a single text file containing: The graph, in adjacent list format The weight matrix The required number of clusters

The output of your program should be a text file containing the clusters, represented as list of nodes on different rows. As a convention, nodes should appear in numerical order. Clusters should be sorted by numerical order of their first node.
example of output:
0 4 1 2 3
Your program should be able to recognize invalid input of the following nature:
Mismatch between size of adjacency list and weight matrix. You can assume that the adjacency list and the weight matrix will always be present in the input file and contain only numbers, but it is possible that their sizes do not match.
Request for an invalid number n of clusters (nnumber of nodes in the graph or n missing) In both cases, the output file should be left empty.
It is NOT allowed to use vector classes or other classes provided in the STL.
Example 1 of input 1 2 34 02 3 0 13 0 12 0 03452 3 0 2 4-999 4 20 1-999 5410-999 2 -999-999 -9990 2 999 represents infinite distance (no connection between two nodes). This input corresponds to the following weighted, undirected graph 3 1 0 4 2 4 2 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
