Topological Sort & Critical Path
Topological Sort & Critical Path
S.Kavitha
Head & Assistant Professor
Department of Computer Science
Sri Sarada Niketan College of Science for
Women,Karur.
ACTIVITY NETWORK
Activity network is a digraph in which the vertices represent
activities or tasks and edges represent precedence relation
between tasks.
The topological sorting is arranging the vertices of the graph
on some order
Activity network is also a type of topological ordering where
the vertices of a graph are connected based on some
dependencies.
Topological sorting is possible only for acyclic graphs.
EXAMPLE: Task Dependenc
ies
T1 None
T2 T1
T3 T1
T4 T1, T2
T5 T1
T6 T4, T5
T7 T6
Activity network T8 T7
T9 T6, T8
T10 T9
OPOLOGICAL SORT
A topological sort is a linear ordering of vertices in a directed acyclic
graph such that if there is a path from Vi to Vj, then Vj appears after Vi
in the linear ordering.
Topological ordering is not possible. If the graph has a cycle, since
for two vertices v and w on the cycle, v precedes w and w precedes v.
Any DAG has at least one topological ordering, and algorithms are
known for constructing a topological ordering of any DAG in linear
time.
For instance, the vertices of the graph may represent tasks to be
performed, and the edges may represent constraints that one task must
be performed before another; in this application, a topological ordering
is just a valid sequence for the tasks.
.
TO IMPLEMENT THE TOPOLOGICAL SORT,
V3 V4 V5
V6 V7
Adjacency Matrix :-
V1 V2 V3 V4 V5 V6 V7
V1 0 1 1 1 0 0 0
V2 0 0 0 1 1 0 0
V3 0 0 0 0 0 1 0
V4 0 0 1 0 0 1 1
V5 0 0 0 1 0 0 1
V6 0 0 0 0 0 0 0
V7 0 0 0 0 0 1 0
INDEGREE 0 1 2 3 1 3 2
DEQUEUE V1 V2 V5 V4 V3 V7 V6
V3 V4 V5
V6 V7
CRITICAL PATH
The critical path for a directed acyclic graph is the most time-consuming path
originating from the root. Critical path analysis answers the following questions
What is the minimum amount of time needed to complete all activities?
Topologically sort G
for each vertex v ∈ V in linearized order