Question: 1 1 . 2 2 LAB: Graph representations Step 1 : Inspect Vertex.java, Edge.java, and DirectedGraph.java Inspect the Vertex class declaration in the Vertex.java file.

11.22 LAB: Graph representations
Step 1: Inspect Vertex.java, Edge.java, and DirectedGraph.java
Inspect the Vertex class declaration in the Vertex.java file. Access Vertex.java by clicking on the orange arrow next to LabProgram.java at
the top of the coding window. The Vertex class represents a graph vertex and has a string for the vertex label.
Inspect the Edge class declaration in the Edge.java file. The edge class represents a directed graph edge and has references to a from-
vertex and a to-vertex.
Inspect the DirectedGraph abstract class declaration in the DirectedGraph.java file. DirectedGraph is an abstract base class for a directed,
unweighted graph.
Step 2: Inspect AdjacencyListGraph.java and AdjacencyListVertex.java
The AdjacencyListGraph class inherits from DirectedGraph and is declared in AdjacencyListGraph.java. The vertices field is an ArrayList
of AdjacencyListVertex references. The ArrayList contains all the graph's vertices.
The AdjacencyListVertex class inherits from Vertex and is declared in the read only AdjacencyListVertex.java file. The adjacent field is an
ArrayList of references to adjacent vertices.
Step 3: Inspect AdjacencyMatrixGraph.java
The AdjacencyMatrixGraph class inherits from DirectedGraph and is declared in AdjacencyMatrixGraph.java. The vertices field is an
ArrayList of Vertex references. The ArrayList contains all the graph's vertices. The matrixRows field is an ArrayList of matrix rows. Each
row itself is an ArrayList of boolean values. If matrixRows [x][Y] is true, then an edge exists from vertices x to vertices Y.
Indices in vertices correspond to indices in matrixRows. So if vertex "C" exists at index 2 in vertices, then row 2 and column 2 in the
matrix correspond to vertex "C".
Step 4: Implement the AdjacencyListGraph class
Implement the required methods in AdjacencyListGraph. Each method has a comment indicating the required functionality. The vertices
ArrayList must be used to store the graph's vertices and must not be removed. New methods can be added, if needed, but existing method
signatures must not change.
Using the codes from above, please make changes to the AdjacencyMatrixGraph.java and AdjacencyListGraph.java, the code for this specific file is missing in the answer, thank you.

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 Accounting Questions!