Question: Work with JAVA: You are required to implement the Breadth First Search and Depth First Search algorithms 1: Request the user to determine the order

Work with JAVA: You are required to implement the Breadth First Search and Depth First Search algorithms 1: Request the user to determine the order (IVI) and size (IEI) of the graph. 2: Generate IEI random ones into the adjacency matrix/list (Adj) to make a random directed graph. 3: Print the resulting adjacency matrix/list. Part A: 1: Request the user to determine the starting vertex (u) for Breadth First Search BFS and Depth First Search DES visit algorithms 2: Call BFS function to find the vertices reachable from vertex u and print the shortest paths and their lengths/distances 3: Call DES visit function to find the vertices reachable from vertex u and for each vertex print the start/finish time Part B: In this part, print the topological order of the vertices 1: Run DFS function tocheck if the graph is a DAG (directed acyclic graph): Search for backward edges. If there are any, (the graph has a cycle.) print: "Cycledetected, topological sort is impossible" 2: If the graph is DAG, (while running DFS): Insert the vertex into a linked 1list as it finishes * Using your linked 1ist, print the topological order of the vertices along with their start/finish time Work with JAVA: You are required to implement the Breadth First Search and Depth First Search algorithms 1: Request the user to determine the order (IVI) and size (IEI) of the graph. 2: Generate IEI random ones into the adjacency matrix/list (Adj) to make a random directed graph. 3: Print the resulting adjacency matrix/list. Part A: 1: Request the user to determine the starting vertex (u) for Breadth First Search BFS and Depth First Search DES visit algorithms 2: Call BFS function to find the vertices reachable from vertex u and print the shortest paths and their lengths/distances 3: Call DES visit function to find the vertices reachable from vertex u and for each vertex print the start/finish time Part B: In this part, print the topological order of the vertices 1: Run DFS function tocheck if the graph is a DAG (directed acyclic graph): Search for backward edges. If there are any, (the graph has a cycle.) print: "Cycledetected, topological sort is impossible" 2: If the graph is DAG, (while running DFS): Insert the vertex into a linked 1list as it finishes * Using your linked 1ist, print the topological order of the vertices along with their start/finish time
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
