Write a program to read integers into an n x n array. Then determine whether that matrix is a valid adjacency matrix for a simple undirected graph. If the matrix represents a valid adjacency matrix, find the degree of each vertex along with the total number of edges. If the matrix does not represent a valid adjacency matrix, output INVALID

Sample input file:

2
4
0 0 1 1
0 0 0 1
1 0 0 0
0 1 0 0
5
0 1 1 0 1
1 0 0 1 0
1 0 0 0 1
0 1 0 0 1
1 0 1 1 0

Sample output file:

Cerise Wuthrich
Matrix 1
INVALID

Matrix 2
Degree of:
Vertex A: 3
Vertex B: 2
Vertex C: 2
Vertex D: 2
Vertex E: 3
Number of edges: 6

Specific requirements:

  • Output your name at the top of the output file.
  • The first number in the input file indicates the number of adjacency matrices in the file.
  • For each set of data, there will be an integer n indicating the number of vertices for the current graph.
  • Following that will be n rows with n entries each of integers.
  • You must use arrays or vectors in this program.
  • If you use arrays, you must dynamically allocate memory for each array and properly free up that memory when you finish processing that particular matrix (array).
  • There will not be more than 26 vertices.
  • No global variables!
  • Label vertices A, B, C, etc.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.