














































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















































The topological sorting problem: given a directed, acyclic graph G = ( V , E ) , find a linear ordering of the vertices such that for all ( v , w ) E , v precedes w in the ordering.
A
B C
F
D (^) E
The topological sorting problem: given a directed, acyclic graph G = ( V , E ) , find a linear ordering of the vertices such that for all ( v , w ) E , v precedes w in the ordering.
A
B C
F
D
A D E
E
B F C
Any linear ordering in which all the arrows go to the right.
The topological sorting problem: given a directed, acyclic graph G = ( V , E ) , find a linear ordering of the vertices such that for all ( v , w ) E , v precedes w in the ordering.
A
B C
F
D
A D F
E
B E C
Any linear ordering in which all the arrows go to the right.
This is not a topological ordering. Docsity.com
The topological sorting algorithm: Identify the subset of vertices that have no incoming edge. (In general, this subset must be nonempty—why?)
A
B C
F
D (^) E
The topological sorting algorithm: Identify the subset of vertices that have no incoming edge. (In general, this subset must be nonempty—because the graph is acyclic.)
A
B C
F
D (^) E
The topological sorting algorithm: Remove it, and its outgoing edges, and add it to the output.
A
B C
F
D (^) E
The topological sorting algorithm: Again, identify the subset of vertices that have no incoming edge,...
A
B C
F
D (^) E
The topological sorting algorithm: Again, identify the subset of vertices that have no incoming edge, select one of them, remove it and any outgoing edges, and put it in the output.
A
B C F
D (^) E
The topological sorting algorithm: Again, identify the subset of vertices that have no incoming edge, select one of them, remove it and any outgoing edges, and put it in the output.
A
B C F
D (^) E
The topological sorting algorithm: Again, identify the subset of vertices that have no incoming edge, select one of them, remove it and any outgoing edges, and put it in the output.
A B
C F
D (^) E
The topological sorting algorithm: Again, identify the subset of vertices that have no incoming edge, select one of them, remove it and any outgoing edges, and put it in the output.
A F B C
D (^) E