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

icon
Related questions
Question
Write java program to store any given graph using the following strategies:
Task 1. Adjacency Matrix (a regular v × 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.
b
a
A sample output for Task 1 is given below.
Enter number of vertices:
4
Enter list of vertices:
ABCD
Enter 1 for Yes and 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
Does C has an edge with D
1
Does D has an
1
edge with A
edge with B
Does D has an edge with C
1
Does D has an
1
Does D has an edge with D
0
C
Following graph is stored
0 1 1 1
100 1
0 1 0 1
1 1 10
Transcribed Image Text:Write java program to store any given graph using the following strategies: Task 1. Adjacency Matrix (a regular v × 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. b a A sample output for Task 1 is given below. Enter number of vertices: 4 Enter list of vertices: ABCD Enter 1 for Yes and 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 Does C has an edge with D 1 Does D has an 1 edge with A edge with B Does D has an edge with C 1 Does D has an 1 Does D has an edge with D 0 C Following graph is stored 0 1 1 1 100 1 0 1 0 1 1 1 10
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Similar questions