Question: ?IN JAVA (BOOK: data structure and algorithms 2nd edition) QUESTION: 13.3 Modify the dfs.java program (Listing 13.1) to display a connectivity table for a directed
?IN JAVA (BOOK: data structure and algorithms 2nd edition)
QUESTION:
13.3 Modify the dfs.java program (Listing 13.1) to display a connectivity table for a directed graph, as described in the section Connectivity in Directed Graphs. ?
?PLEASE USE THE MAIN METHOD GIVEN BELOW:
public static void main(String[] args)
{
Graph theGraph = new Graph();
theGraph.addVertex('A'); // 0 (start for dfs)
theGraph.addVertex('B'); // 1
theGraph.addVertex('C'); // 2
theGraph.addVertex('D'); // 3
theGraph.addVertex('E'); // 4
theGraph.addEdge(0, 2); // AC
theGraph.addEdge(1, 0); // BA
theGraph.addEdge(1, 4); // BE
theGraph.addEdge(3, 4); // DE
theGraph.addEdge(4, 2); // EC
System.out.println("Connectivity Table");
theGraph.makeTable();
System.out.println(" ");
theGraph.adjMatDisplay();
} // end main()
PLEASE MAKE THE OUTPUT IS SAME AS GIVEN BELOW:
OUTPUT:
Connectivity Table
AC
BACE
C
DEC
EC
A B C D E
==========
A 0 0 1 0 0
B 1 0 0 0 1
C 0 0 0 0 0
D 0 0 0 0 1
E 0 0 1 0 0
?PLEASE DO IT AS SOON AS POSSIBLE.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
