Write Java Program Generates Random Connected Undirected Graph Program Include Steps 1 Ask Q37186879

Write a java program that generates a random connectedundirected graph.
Your program should include these steps:

1. Ask the number of vertices to the user (n)

2. Create an adjacency matrix of n * n (with undirectededges)

3. Print the matrix

4. Check if the matrix is connected (you can use DFSalgorithm)

5. If the graph is not connected make it connected

6. Print the matrix again

7. Apply DFS to find a possible spanning tree

8. Print the result (vertices and edges)

9. Apply BFS to find a possible spanning tree

10. Print the result (vertices and edges)


Answer


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.