Write java program to store any given graph using the following strategies: Task 1. Adjacency Matrix (a regular vx v 2-D array) Your program must ask the number of vertices and then the list of vertices to store. Afterwards, the adjacent vertices to each of the vertex to store the information. You may consider the following simple graph to test your program. a b A sample output for Task 1 is given below. Enter number of vertices: 4 Enter list of vertices: ABCD Enter 1 for Yes and 0 for No Does A has an edge with A 0 Does A has an edge with B 1 Does A has an edge with C 1 Does A has an edge with D 1 Does B has an edge with A 1 Does B has an edge with B 0 Does B has an edge with C 0 Does B has an edge with D 1 Does C has an edge with A 0 Does C has an edge with B 1 Does C has an edge with C 0 edge with D Does C has an 1 Does D has an edge with A 1 Does D has an edge with B 1 Does D has an edge with C 1 Does D has an edge with D 0 с Following graph is stored 0 1 1 1 100 1 0 1 0 1 1 1 1 0
Write java program to store any given graph using the following strategies: Task 1. Adjacency Matrix (a regular vx v 2-D array) Your program must ask the number of vertices and then the list of vertices to store. Afterwards, the adjacent vertices to each of the vertex to store the information. You may consider the following simple graph to test your program. a b A sample output for Task 1 is given below. Enter number of vertices: 4 Enter list of vertices: ABCD Enter 1 for Yes and 0 for No Does A has an edge with A 0 Does A has an edge with B 1 Does A has an edge with C 1 Does A has an edge with D 1 Does B has an edge with A 1 Does B has an edge with B 0 Does B has an edge with C 0 Does B has an edge with D 1 Does C has an edge with A 0 Does C has an edge with B 1 Does C has an edge with C 0 edge with D Does C has an 1 Does D has an edge with A 1 Does D has an edge with B 1 Does D has an edge with C 1 Does D has an edge with D 0 с Following graph is stored 0 1 1 1 100 1 0 1 0 1 1 1 1 0
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images