Using topological sort to generate an order in which the courses have to be taken to handle dependencies.