Question: This program exercises graphs. # Replace any comments with your own code statement(s) # to accomplish the specified task. # Do not change
This program exercises graphs.
# Replace any "
# The following files must be in the same folder: # abstractcollection.py # graph.py
from graph import LinkedDirectedGraph
# Part 1: # Complete the following function: def topologicalSort(graph): #
graph = LinkedDirectedGraph()
# The graph represents the following course prerequisites: # A requires nothing # B requires nothing # C requires A # D requires A, B, and C # E requires C # F requires B and D # G requires E and F # H requires C, F, and G
# Part 2: # Add the vertices: #
# Part 3: # Add the edges: #
print("Graph:") print(graph) print()
print("Courses:") # Part 4: # Display each vertex on a separate line: #
print("Prerequisites:") # Part 5: # Display each edge on a separate line: #
print("One possible order to take the courses:") # Part 6: # Display the courses in prerequisite (topological) order: #
PLEASE HELP! THANKS! I WILL RATE YOU!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
