Question: language: java Create a class: AdjListGraph.java, and just submit AdjListGraph.java. where Step 1: Please implement a graph by adjacency list. Step 2: Write a method:

 language: java Create a class: AdjListGraph.java, and just submit AdjListGraph.java. where

language: java

Create a class: AdjListGraph.java, and just submit AdjListGraph.java. where Step 1: Please implement a graph by adjacency list. Step 2: Write a method: void dfs(){\\TO-DO); which can traverse a graph by DFS (stack based or recursive) The class adjListGraph.java will be test as public class Test {public static void main (String[] args) {AdjListGraph theGraph = new AdjListGraph(); theGraph.addVertex('A');//0 (start for dfs) theGraph.addVertext('B');//1 theGraph.addVertext('C');//2 theGraph.addVertext('D');//3 theGraph.addVertext('E');//4 theGraph.addVertext('F');//5 theGraph.addEdge(0, 1);//AB theGraph.addEdge(0, 2);//AC theGraph.addEdge(1, 3);//BD theGraph.addEdge(2, 4);//CE theGraph.addEdge(2, 3);//CD theGraph.addEdge(0, 3);//AD theGraph.addEdge(3, 4);//DE theGraph.addEdge(3, 5);//DE System. out print ("dfs visits: ----------------- "); theGraph.dfs(); System.out.println();}//end main ()}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!