2. Definition
Topological sorting for a directed acyclic graph(DAG)
Linear ordering of vertices
For every edge U-V of a directed graph,
For every edge U-V of a directed graph,
Vertex u will come before vertex v in the ordering
3. Source Removal Algorithm
Direct implementation of the decrease and conquers
method
Steps
Identify a vertex(source) from a remaining digraph
Identify a vertex(source) from a remaining digraph
with no incoming edges
If there are more than one such vertices, then break the tie
randomly.
Delete it along with all the edges outgoing from it
Solution: deleted order of the vertices
4. Example
Consider a set of 5 required courses {C1,C2,C3,C4,C5} a
part-time student has to take in some degree program.
The courses can be taken in any order as long as the
following course prerequisites are met:
C1 and C2 have no prerequisites
C1 and C2 have no prerequisites
C3 requires C1 and C2
C4 requires C3
C5 requires C3 and C4
The student can take only one course per term.
In which order should the student take the courses?
5. Digraph
Prerequisite structure of five courses
C1 and C2 have no prerequisites
C3 requires C1 and C2
C3 requires C1 and C2
C4 requires C3
C5 requires C3 and C4