Question: Goal Design and implement an algorithm to determine if an undirected simple graph is connected Details Input to your program consists of an integer n
Goal Design and implement an algorithm to determine if an undirected simple graph is connected Details Input to your program consists of an integer n representing the number of vertices followed an adjacency matrix of n rows, each row with n entries. Each entry of the nx n adjacency matrix, will contain a 1 if there is an edge between the corresponding vertices or a 0 if there is no edge. Output the number of vertices in the graph and the adjacency matrix then use the recursive depth first search algorithm, see slide 4 of the GraphTheoryAlgorithms slides, to traverse the graph and output the number of vertices found by DFS along with a list of those vertices in the order visited/marked. Determine if the DFS has visited every vertex. If so, output "Conclusion: The graph is connected." Otherwise output "Conclusion: The graph is not connected." Output is required to be formatted as in the examples below and in the order given. EXAMPLE 1: Matrix tion 00100 00100 11011 00101 00110 // 5 vertices in graph. There will be 5 rows of the matrix, each with 5 entries. // Row 1 of Adjacency Matrix, vertices adjacent to vertex 1 // Row 2 of Adjacency Matrix, vertices adjacent to vertex 2 // Row 3 of Adjacency Matrix, vertices adjacent to vertex 3 // Row 4 of Adjacency Matrix, vertices adjacent to vertex 4 // Row 5 of Adjacency Matrix, vertices adjacent to vertex 5 Output Number of Vertices: 5 Matrix 00100 00100 11011 00101 00110 Number of Vertices Visited by DFS: 5 DFS Vertices: 13245 Conclusion: The graph is connected
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
