Topological Sorting: Difference between revisions

From Algorithm Wiki
Jump to navigation Jump to search
(Created page with "== Problem Description== Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for every directed edge u v, vertex u comes before v in the ordering. Topological Sorting for a graph is not possible if the graph is not a DAG. Topological Sorting is mainly used for scheduling jobs from the given dependencies among jobs. In computer science, applications of this type arise in instruction scheduling, ordering of formula cell evaluati...")
 
No edit summary
Line 1: Line 1:
== Problem Description==
{{DISPLAYTITLE:Topological Sorting (Topological Sorting)}}
Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for every directed edge u v, vertex u comes before v in the ordering. Topological Sorting for a graph is not possible if the graph is not a DAG.
== Description ==  


Topological Sorting is mainly used for scheduling jobs from the given dependencies among jobs. In computer science, applications of this type arise in instruction scheduling, ordering of formula cell evaluation when recomputing formula values in spreadsheets, logic synthesis, determining the order of compilation tasks to perform in make files, data serialization, and resolving symbol dependencies in linkers.
Given a graph or network, find a topological sorting of the graph. A list in topological order has a special property. Simply expressed: proceeding from element to element along any path in the network, one passes through the list in one direction only. Stated another way, a list in topological order is such that no element appears in it until after all elements appearing on all paths leading to the particular element have been listed.  


== Bounds Chart ==
== Parameters ==  
[[File:Topological_SortingBoundsChart.png|1050px]]


== Step Chart ==
<pre>V: number of vertices
[[File:Topological_SortingStepChart.png|1050px]]
E: number of edges</pre>
 
== Table of Algorithms ==  
 
{| class="wikitable sortable"  style="text-align:center;" width="100%"
 
! Name !! Year !! Time !! Space !! Approximation Factor !! Model !! Reference


== Improvement Table ==
{| class="wikitable" style="text-align:center;" width="100%"
!width="20%" | Complexity Classes !! width="40%" | Algorithm Paper Links !! width="40%" | Lower Bounds Paper Links
|-
| rowspan="1" | Exp/Factorial
|
|
|-
|-
| rowspan="1" | Polynomial > 3
 
|
| [[Kahn's algorithm (Topological Sorting Topological Sorting)|Kahn's algorithm]] || 1962 || $O(V+E)$ || $O(V)$ auxiliary || Exact || Deterministic || [https://dl.acm.org/doi/10.1145/368996.369025 Time]
|
|-
|-
| rowspan="1" | Cubic
| [[Tarjan's DFS based algorithm (Topological Sorting Topological Sorting)|Tarjan's DFS based algorithm]] || 1976 || $O(V+E)$ || $O(V)$ auxiliary? || Exact || Deterministic || [https://link.springer.com/article/10.1007/BF00268499 Time]
|
|
|-
|-
| rowspan="1" | Quadratic
| [[Dekel; Nassimi & Sahni Parallel Implementation  (Topological Sorting Topological Sorting)|Dekel; Nassimi & Sahni Parallel Implementation ]] || 1981 || $O( log² V)$ || $O(V^{2})$?? || Exact || Parallel || [https://www.proquest.com/docview/920003939?pq-origsite=gscholar&fromopenview=true Time]
|
|
|-
|-
| rowspan="1" | nlogn
|}
|
 
|
== Time Complexity graph ==  
|-
 
| rowspan="1" | Linear
[[File:Topological Sorting - Time.png|1000px]]
| [https://dl.acm.org/doi/10.1145/368996.369025 Kahn's algorithm (1962)]
 
== Space Complexity graph ==
 
[[File:Topological Sorting - Space.png|1000px]]
 
== Pareto Decades graph ==


[https://link.springer.com/article/10.1007/BF00268499 Tarjan's DFS based algorithm (1976) (1976)]
[[File:Topological Sorting - Pareto Frontier.png|1000px]]
|
|-
| rowspan="1" | logn
| [https://epubs.siam.org/doi/abs/10.1137/0210049?journalCode=smjcat Dekel; Nassimi & Sahni (1981) Parallel Implementation  (1981)]
|
|-|}

Revision as of 10:22, 15 February 2023

Description

Given a graph or network, find a topological sorting of the graph. A list in topological order has a special property. Simply expressed: proceeding from element to element along any path in the network, one passes through the list in one direction only. Stated another way, a list in topological order is such that no element appears in it until after all elements appearing on all paths leading to the particular element have been listed.

Parameters

V: number of vertices
E: number of edges

Table of Algorithms

Name Year Time Space Approximation Factor Model Reference
Kahn's algorithm 1962 $O(V+E)$ $O(V)$ auxiliary Exact Deterministic Time
Tarjan's DFS based algorithm 1976 $O(V+E)$ $O(V)$ auxiliary? Exact Deterministic Time
Dekel; Nassimi & Sahni Parallel Implementation 1981 $O( log² V)$ $O(V^{2})$?? Exact Parallel Time

Time Complexity graph

Topological Sorting - Time.png

Space Complexity graph

Topological Sorting - Space.png

Pareto Decades graph

Topological Sorting - Pareto Frontier.png