In Computer Science a Graph is represented using an adjacency matrix. Is matrix is a square matrix whose dimension is the total number of vertices. The following example shows the graphical representation of a graph with 5 vertices, its matrix of adjacency, degree of entry and exit of each vertex, that is, the total number of arrows that enter or leave each vertex (verify in the image) and the loops of the graph, that is say the vertices that connect with themselves To program it, use Object Oriented Programming concepts (Classes, objects, attributes, methods), it can be in Java or in Python. -Declare a constant V with value 5 -Declare a variable called Graph that is a VxV matrix of integers -Define a MENU procedure with the following text GRAPHS 1. Create Graph 2.Show Graph 3. Adjacency between pairs 4.Input degree 5.Output degree 6.Loops 0.exit -Validate MENU so that it receives only valid options (from 0 to 6), otherwise send an error message and repeat the reading -Make the MENU call in the main program -Define a CREATE procedure/function to fill an array with random values between 0 and 1. Where 0 represents no adjacency and 1 indicates that there is. -Make the CREATE call in the main program, receive as parameter the Graph matrix created in point 2 -Define a SHOW procedure/function to print an adjacency matrix, in matrix form -Make the SHOW call in the main program, receive as parameter the Graph matrix created in point 2 - Define an ADJACENCY procedure/function that receives, apart from the array, two integer values and returns a value of true if there is a 1 in those positions of the array and False otherwise. -Make the ADYACENCY call in the main program. To do this, ask and validate (between 1 and V) two vertices of the graph. Indicate if these two vertices are adjacent in the graph. That is, if ADYACENCY returns 1, write “Adjacency”, if they are not, say “Not adjacency”. Remember that the user is going to give values between 1 and V and that the matrix has values from 0 to V-1 -For the Output degree option, use the function/procedure that add rows and do it with each of the rows. Remember that the user will see vertices between 1 and V and that the matrix has values from 0 to V-1 - The MENU keeps repeating until the user presses 0 (exit)
In Computer Science a Graph is represented using an adjacency matrix. Is
matrix is a square matrix whose dimension is the total number of vertices.
The following example shows the graphical representation of a graph with 5 vertices, its matrix
of adjacency, degree of entry and exit of each vertex, that is, the total number of
arrows that enter or leave each vertex (verify in the image) and the loops of the graph, that is
say the vertices that connect with themselves
To program it, use Object Oriented
-Declare a constant V with value 5
-Declare a variable called Graph that is a VxV matrix of integers
-Define a MENU procedure with the following text
GRAPHS
1. Create Graph
2.Show Graph
3. Adjacency between pairs
4.Input degree
5.Output degree
6.Loops
0.exit
-Validate MENU so that it receives only valid options (from 0 to 6), otherwise send an error message and repeat the reading
-Make the MENU call in the main program
-Define a CREATE procedure/function to fill an array with random values between 0 and 1. Where 0 represents no
adjacency and 1 indicates that there is.
-Make the CREATE call in the main program, receive as
parameter the Graph matrix created in point 2
-Define a SHOW procedure/function to print an adjacency matrix, in matrix form
-Make the SHOW call in the main program, receive as
parameter the Graph matrix created in point 2
- Define an ADJACENCY procedure/function that receives, apart from the array, two integer values and returns a value of true if there is a 1 in those positions of the array and False otherwise.
-Make the ADYACENCY call in the main program. To do this, ask and validate (between 1 and V) two vertices of the graph. Indicate if these two vertices are adjacent in the graph. That is, if ADYACENCY returns 1, write “Adjacency”, if they are not, say “Not adjacency”. Remember that the user is going to give values between 1 and V and that the matrix has values from 0 to V-1
-For the Output degree option, use the function/procedure that
add rows and do it with each of the rows. Remember that the user will see vertices between 1 and V and that the matrix has values from 0 to V-1
- The MENU keeps repeating until the user presses 0 (exit)


Step by step
Solved in 5 steps with 2 images









