Answered step by step
Verified Expert Solution
Question
1 Approved Answer
[ Data Structures ] Graphs ( using C++ ). Write a program to implement an undirected graph. Use the adjacency matrix to implement the graph.
[Data Structures] Graphs (using C++).
Write a program to implement an undirected graph. Use the adjacency matrix to implement the graph. Let your program be menu driven. Represent a vertex by using the index value of the array. Let the maximum number of vertices be 100. For example, if the number of vertices is 5, the vertices are 0,1, 2, 3 and 4. Start the program by prompting the user for the number of vertices. Then create a graph with no edges. Allowing the user the following options: 1. Insert an edge 2. Delete an edge 3. Print Adjacency Matrix 4. List all vertices that are adjacent to a specified vertex. 5. Print out vertices using depth first search 6. Print out vertices using breadth first search 7. Check for connectivity 8. Check for completeness 9. Exit program Programming guidelines - Options 1, 2, 3, 4 and 9 are required. Additional implemented options are extra credit. Option 1 - Allows the user to insert an edge. The user must specify the two vertices that the edge will connect. Option 2 - Allows the user to delete an edge. The user must specify the two vertices connecting the edge that is to be deleted. Option 3 - Print out the adjacency matrix (one row per line of output) Option 4 - The user enters a vertex, and the program prints out all of the vertices that are adjacent to the specified vertex. Option 5 - Print out the vertices using the depth first search Option 6 - Print out the vertices using the breadth first search Option 7 - Print out whether or not the graph is connected Option 8 - Print out whether or not the graph is a complete graph
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started