Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Step 1 : Inspect Vertex.py , Edge.py , and DirectedGraph.py Inspect the Vertex class declaration in the Vertex.py file. Access Vertex.py by clicking on the
Step : Inspect Vertex.py Edge.py and DirectedGraph.py
Inspect the Vertex class declaration in the Vertex.py file. Access Vertex.py by clicking on the orange arrow next to main.py 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.py file. The edge class represents a directed graph edge and has references to a fromvertex and a tovertex.
Inspect the DirectedGraph abstract class declaration in the DirectedGraph.py file. DirectedGraph is an abstract base class for a directed, unweighted graph.
Step : Inspect AdjacencyListGraph.py and AdjacencyListVertex.py
The AdjacencyListGraph class inherits from DirectedGraph and is declared in AdjacencyListGraph.py The vertices attribute is a list of AdjacencyListVertex references. The list contains all the graph's vertices.
The AdjacencyListVertex class inherits from Vertex and is declared in the read only AdjacencyListVertex.py file. The adjacent attribute is a list of references to adjacent vertices.
Step : Inspect AdjacencyMatrixGraph.py
The AdjacencyMatrixGraph class inherits from DirectedGraph and is declared in AdjacencyMatrixGraph.py The vertices attribute is a list of Vertex references. The list contains all the graph's vertices. The matrixrows attribute is a list of matrix rows. Each row itself is a list of bool values. If matrixrowsXY is true, then an edge exists from verticesX to verticesY
Indices in vertices correspond to indices in matrixrows. So if vertex C exists at index in vertices, then row and column in the matrix correspond to vertex C
Step : Implement the AdjacencyListGraph class
Implement the required methods in AdjacencyListGraph. Each method has a comment indicating the required functionality. The vertices list 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.
Step : Implement the AdjacencyMatrixGraph class
Implement the required methods in AdjacencyMatrixGraph. Each method has a comment indicating the required functionality. The vertices and matrixrows lists must be used to store the graph's vertices and adjacency matrix, respectively. Both vertices and matrixrows lists must not be removed. New methods can be added, if needed, but existing method signatures must not change.
Step : Test in develop mode, then submit
File main.py contains test cases for each graph operation. The test operations are first run on an AdjacencyListGraph. Then the same test operations are run on an AdjacencyMatrixGraph. Running code in develop mode displays the test results.
After each method is implemented and all tests pass in develop mode, submit the code. The unit tests run on submitted code are similar, but use different graphs and perform direct verification of the graphs internal attributes.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started