SlideShare a Scribd company logo
TOPOLOGICAL SORT
A. D. PATEL INSTITUTE OF TECHNOLOGY
ANALYSIS AND DESIGN OF ALGORITHMS(2150703) : A.Y. 2018-19
DEPARTMENT OF INFORMATION TECHNOLOGY
A D PATEL INSTITUTE OF TECHNOLOGY (ADIT)
NEW VALLABH VIDYANAGAR, ANAND, GUJARAT
GUIDED BY:
PROF. DINESH J. PRAJAPATI
(DEPT OF IT, ADIT)
PREPARED BY:
KUNAL R. KATHE(160010116021)
DHRUV V. SHAH (160010116053)
RUSHIL V. PATEL (160014116001)
B.E. (IT) SEM - V
8TH OCTOBER, 2018
2
Outline
 Introduction
 Directed Acyclic Graph(DAG)
 Algorithm
 Example
 Applications
 References
3
Introduction
WHAT IS TOPOLOGICAL SORT ?
 For a directed acyclic graph G=(V,E)
 A topological sort is an ordering of all of G’s vertices
 v1, v2, v3,….,vn such that …
 Vertex u comes before vertex v if edge (u,v) belongs to G
 So,formally for every egde (vi,vk) in E ,i<k
4
Contd...
Definition:
A topological sort or topological ordering of a directed
ayclic graph is a linear ordering of its vertices such that
for every directed edge (u,v) from vertex u to v, u
comes before v in the ordering.
5
Contd...
0 1
5
2
4
3
For example, a topological sorting
of the given graph is “5 4 2 3 1 0”.
There can be more then one
topological sorting for a graph.
For example , another
topological sorting for the graph
is “4 5 2 3 1 0”.The first vertex
in topological sorting is always
a vertex with in-degree as “0”
( a vertex with no incoming edges).
 So, the Topological Sorting is NOT UNIQUE.
 Also it can only be applied to Directed Acyclic Graphs(DAG).
6
Directed Acyclic Graph
A directed acyclic graph is an acyclic graph that has a direction as well
as a lack of cycles.
1 2
4
3
5 7
6
Vertices Set:
{1,2,3,4,5,6,7}
Edge Set: {(1,2),(1,3),(2,4),
(2,5),(3,6),(4,7),
(5,7),(6,7)}
A directed acyclic graph has a topological ordering. This means that the
nodes are ordered so that the starting node has a lower value than the
ending node.
7
Contd...
8
Algorithm
1
2
3
4
5
9
Example
1 2
43 5
6 7
Identify nodes having in degree ‘0’
Select a node and delete it with its
edges then add node to output
Select Node : 1
Output :
1
10
Contd…
2
43 5
6 7
Identify nodes having in degree ‘0’
Select a node and delete it with its
edges then add node to output
Select Node : 2
Output :
1 2
11
Contd…
43 5
6 7
Identify nodes having in degree ‘0’
Select a node and delete it with its
edges then add node to output
Select Node : 5
Output :
1 2 5
12
Contd…
43
6 7
Identify nodes having in degree ‘0’
Select a node and delete it with its
edges then add node to output
Select Node : 4
Output :
1 2 5 4
13
Contd…
3
6 7
Identify nodes having in degree ‘0’
Select a node and delete it with its
edges then add node to output
Select Node : 3
Output :
1 2 5 4 3
14
Contd…
6 7
Identify nodes having in degree ‘0’
Select a node and delete it with its
edges then add node to output
Select Node : 6
Output :
1 2 5 4 3 6
Select Node : 7
7
15
Applications
 1] Build Systems :
 We have various IDE’s like Ecllipse , Netbeans etc. We have to
build a project which has many libraries dependent on each
 other then IDE uses Topological Sort to decide which library to
 include or build first.
 2] Advanced-Packaging Tool(apt-get) :
 In Linux apt-get is used to install softwares in the system. The command
 “apt-get install VLC” is used. It is the way in Linux to install and remove
 softwares.
16
Contd...
 3] Task Scheduling :
 Topological Sort is helpful in scheduling interdependent task to
know which rask should proceed which one.
 4] Pre- Requisite Problems:
 We often come across situations where we need to finish one job in order to
 proceed the next one. For ex, In University structure, we need to complete
 basic Algorithm course to study an Advance Algorithm course. So, there
 exist a pre- requisite and we can know this by doing a topological sort on all.
17
QUERY ?
18

More Related Content

What's hot

Graphs in Data Structure
 Graphs in Data Structure Graphs in Data Structure
Graphs in Data Structure
hafsa komal
 
Bubble sort
Bubble sortBubble sort
Bubble sort
Manek Ar
 
Depth First Search ( DFS )
Depth First Search ( DFS )Depth First Search ( DFS )
Depth First Search ( DFS )
Sazzad Hossain
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
eShikshak
 
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data Structure
Jeanie Arnoco
 
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I 	LINEAR DATA STRUCTURES – LIST 	UNIT I 	LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST
Kathirvel Ayyaswamy
 
SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS
Md. Shafiuzzaman Hira
 
Graphs in data structure
Graphs in data structureGraphs in data structure
Graphs in data structure
hamza javed
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - Graph
Madhu Bala
 
Quick sort
Quick sortQuick sort
Quick sort
Dhruv Sabalpara
 
Algorithms Lecture 7: Graph Algorithms
Algorithms Lecture 7: Graph AlgorithmsAlgorithms Lecture 7: Graph Algorithms
Algorithms Lecture 7: Graph Algorithms
Mohamed Loey
 
Bfs and dfs in data structure
Bfs and dfs in  data structure Bfs and dfs in  data structure
Bfs and dfs in data structure
Ankit Kumar Singh
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
Krish_ver2
 
Bubble sort | Data structure |
Bubble sort | Data structure |Bubble sort | Data structure |
Bubble sort | Data structure |
MdSaiful14
 
Dfs presentation
Dfs presentationDfs presentation
Dfs presentationAlizay Khan
 
Dijkstra's algorithm presentation
Dijkstra's algorithm presentationDijkstra's algorithm presentation
Dijkstra's algorithm presentation
Subid Biswas
 
Data Structures - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]Data Structures - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]
Muhammad Hammad Waseem
 
DFS and BFS
DFS and BFSDFS and BFS
DFS and BFS
satya parsana
 

What's hot (20)

Graphs in Data Structure
 Graphs in Data Structure Graphs in Data Structure
Graphs in Data Structure
 
Bubble sort
Bubble sortBubble sort
Bubble sort
 
Depth First Search ( DFS )
Depth First Search ( DFS )Depth First Search ( DFS )
Depth First Search ( DFS )
 
Disjoint sets
Disjoint setsDisjoint sets
Disjoint sets
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
 
Quick sort-Data Structure
Quick sort-Data StructureQuick sort-Data Structure
Quick sort-Data Structure
 
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I 	LINEAR DATA STRUCTURES – LIST 	UNIT I 	LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST
 
SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS
 
Graphs in data structure
Graphs in data structureGraphs in data structure
Graphs in data structure
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - Graph
 
Quick sort
Quick sortQuick sort
Quick sort
 
Algorithms Lecture 7: Graph Algorithms
Algorithms Lecture 7: Graph AlgorithmsAlgorithms Lecture 7: Graph Algorithms
Algorithms Lecture 7: Graph Algorithms
 
Bfs and dfs in data structure
Bfs and dfs in  data structure Bfs and dfs in  data structure
Bfs and dfs in data structure
 
single linked list
single linked listsingle linked list
single linked list
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
 
Bubble sort | Data structure |
Bubble sort | Data structure |Bubble sort | Data structure |
Bubble sort | Data structure |
 
Dfs presentation
Dfs presentationDfs presentation
Dfs presentation
 
Dijkstra's algorithm presentation
Dijkstra's algorithm presentationDijkstra's algorithm presentation
Dijkstra's algorithm presentation
 
Data Structures - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]Data Structures - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]
 
DFS and BFS
DFS and BFSDFS and BFS
DFS and BFS
 

Similar to Topological Sorting

EdSketch: Execution-Driven Sketching for Java
EdSketch: Execution-Driven Sketching for JavaEdSketch: Execution-Driven Sketching for Java
EdSketch: Execution-Driven Sketching for Java
Lisa Hua
 
Efficient SIMD Vectorization for Hashing in OpenCL
Efficient SIMD Vectorization for Hashing in OpenCLEfficient SIMD Vectorization for Hashing in OpenCL
Efficient SIMD Vectorization for Hashing in OpenCL
Jonas Traub
 
Vhdl code and project report of arithmetic and logic unit
Vhdl code and project report of arithmetic and logic unitVhdl code and project report of arithmetic and logic unit
Vhdl code and project report of arithmetic and logic unit
Nikhil Sahu
 
JAVA BASED VISUALIZATION AND ANIMATION FOR TEACHING THE DIJKSTRA SHORTEST PAT...
JAVA BASED VISUALIZATION AND ANIMATION FOR TEACHING THE DIJKSTRA SHORTEST PAT...JAVA BASED VISUALIZATION AND ANIMATION FOR TEACHING THE DIJKSTRA SHORTEST PAT...
JAVA BASED VISUALIZATION AND ANIMATION FOR TEACHING THE DIJKSTRA SHORTEST PAT...
ijseajournal
 
Dynamic sorting algorithm vizualizer.pdf
Dynamic sorting algorithm vizualizer.pdfDynamic sorting algorithm vizualizer.pdf
Dynamic sorting algorithm vizualizer.pdf
AgneshShetty
 
mini project_shortest path visualizer.pptx
mini project_shortest path visualizer.pptxmini project_shortest path visualizer.pptx
mini project_shortest path visualizer.pptx
tusharpawar803067
 
GRAPHICAL STRUCTURES in our lives
GRAPHICAL STRUCTURES in our livesGRAPHICAL STRUCTURES in our lives
GRAPHICAL STRUCTURES in our lives
xryuseix
 
Representing and visiting graphs
Representing and visiting graphsRepresenting and visiting graphs
Representing and visiting graphs
Fulvio Corno
 
Ds lab manual by s.k.rath
Ds lab manual by s.k.rathDs lab manual by s.k.rath
Ds lab manual by s.k.rathSANTOSH RATH
 
NVIDIA HPC ソフトウエア斜め読み
NVIDIA HPC ソフトウエア斜め読みNVIDIA HPC ソフトウエア斜め読み
NVIDIA HPC ソフトウエア斜め読み
NVIDIA Japan
 
Java parallel programming made simple
Java parallel programming made simpleJava parallel programming made simple
Java parallel programming made simple
Ateji Px
 
Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)
Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)
Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)
Austin Benson
 
Lab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer GraphicsLab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer Graphics
Rup Chowdhury
 
Intro to OpenGL ES 2.0
Intro to OpenGL ES 2.0Intro to OpenGL ES 2.0
Intro to OpenGL ES 2.0
Oleksandr Kozubets
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm Analysis
Mary Margarat
 
“New Methods for Implementation of 2-D Convolution for Convolutional Neural N...
“New Methods for Implementation of 2-D Convolution for Convolutional Neural N...“New Methods for Implementation of 2-D Convolution for Convolutional Neural N...
“New Methods for Implementation of 2-D Convolution for Convolutional Neural N...
Edge AI and Vision Alliance
 
Project seminar ppt_steelcasting
Project seminar ppt_steelcastingProject seminar ppt_steelcasting
Project seminar ppt_steelcasting
Rudra Narayan Paul
 
Sorting_project_2.pdf
Sorting_project_2.pdfSorting_project_2.pdf
Sorting_project_2.pdf
VrushaliSathe2
 
Cadancesimulation
CadancesimulationCadancesimulation
Cadancesimulation
Gautham Reddy
 
All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithmSrikrishnan Suresh
 

Similar to Topological Sorting (20)

EdSketch: Execution-Driven Sketching for Java
EdSketch: Execution-Driven Sketching for JavaEdSketch: Execution-Driven Sketching for Java
EdSketch: Execution-Driven Sketching for Java
 
Efficient SIMD Vectorization for Hashing in OpenCL
Efficient SIMD Vectorization for Hashing in OpenCLEfficient SIMD Vectorization for Hashing in OpenCL
Efficient SIMD Vectorization for Hashing in OpenCL
 
Vhdl code and project report of arithmetic and logic unit
Vhdl code and project report of arithmetic and logic unitVhdl code and project report of arithmetic and logic unit
Vhdl code and project report of arithmetic and logic unit
 
JAVA BASED VISUALIZATION AND ANIMATION FOR TEACHING THE DIJKSTRA SHORTEST PAT...
JAVA BASED VISUALIZATION AND ANIMATION FOR TEACHING THE DIJKSTRA SHORTEST PAT...JAVA BASED VISUALIZATION AND ANIMATION FOR TEACHING THE DIJKSTRA SHORTEST PAT...
JAVA BASED VISUALIZATION AND ANIMATION FOR TEACHING THE DIJKSTRA SHORTEST PAT...
 
Dynamic sorting algorithm vizualizer.pdf
Dynamic sorting algorithm vizualizer.pdfDynamic sorting algorithm vizualizer.pdf
Dynamic sorting algorithm vizualizer.pdf
 
mini project_shortest path visualizer.pptx
mini project_shortest path visualizer.pptxmini project_shortest path visualizer.pptx
mini project_shortest path visualizer.pptx
 
GRAPHICAL STRUCTURES in our lives
GRAPHICAL STRUCTURES in our livesGRAPHICAL STRUCTURES in our lives
GRAPHICAL STRUCTURES in our lives
 
Representing and visiting graphs
Representing and visiting graphsRepresenting and visiting graphs
Representing and visiting graphs
 
Ds lab manual by s.k.rath
Ds lab manual by s.k.rathDs lab manual by s.k.rath
Ds lab manual by s.k.rath
 
NVIDIA HPC ソフトウエア斜め読み
NVIDIA HPC ソフトウエア斜め読みNVIDIA HPC ソフトウエア斜め読み
NVIDIA HPC ソフトウエア斜め読み
 
Java parallel programming made simple
Java parallel programming made simpleJava parallel programming made simple
Java parallel programming made simple
 
Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)
Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)
Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)
 
Lab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer GraphicsLab Practices and Works Documentation / Report on Computer Graphics
Lab Practices and Works Documentation / Report on Computer Graphics
 
Intro to OpenGL ES 2.0
Intro to OpenGL ES 2.0Intro to OpenGL ES 2.0
Intro to OpenGL ES 2.0
 
Data Structures and Algorithm Analysis
Data Structures  and  Algorithm AnalysisData Structures  and  Algorithm Analysis
Data Structures and Algorithm Analysis
 
“New Methods for Implementation of 2-D Convolution for Convolutional Neural N...
“New Methods for Implementation of 2-D Convolution for Convolutional Neural N...“New Methods for Implementation of 2-D Convolution for Convolutional Neural N...
“New Methods for Implementation of 2-D Convolution for Convolutional Neural N...
 
Project seminar ppt_steelcasting
Project seminar ppt_steelcastingProject seminar ppt_steelcasting
Project seminar ppt_steelcasting
 
Sorting_project_2.pdf
Sorting_project_2.pdfSorting_project_2.pdf
Sorting_project_2.pdf
 
Cadancesimulation
CadancesimulationCadancesimulation
Cadancesimulation
 
All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithm
 

More from ShahDhruv21

Semantic net in AI
Semantic net in AISemantic net in AI
Semantic net in AI
ShahDhruv21
 
Error Detection & Error Correction Codes
Error Detection & Error Correction CodesError Detection & Error Correction Codes
Error Detection & Error Correction Codes
ShahDhruv21
 
Secure Hash Algorithm (SHA)
Secure Hash Algorithm (SHA)Secure Hash Algorithm (SHA)
Secure Hash Algorithm (SHA)
ShahDhruv21
 
Data Mining in Health Care
Data Mining in Health CareData Mining in Health Care
Data Mining in Health Care
ShahDhruv21
 
Data Compression in Data mining and Business Intelligencs
Data Compression in Data mining and Business Intelligencs Data Compression in Data mining and Business Intelligencs
Data Compression in Data mining and Business Intelligencs
ShahDhruv21
 
MongoDB installation,CRUD operation & JavaScript shell
MongoDB installation,CRUD operation & JavaScript shellMongoDB installation,CRUD operation & JavaScript shell
MongoDB installation,CRUD operation & JavaScript shell
ShahDhruv21
 
2D Transformation
2D Transformation2D Transformation
2D Transformation
ShahDhruv21
 
Interpreter
InterpreterInterpreter
Interpreter
ShahDhruv21
 
Pyramid Vector Quantization
Pyramid Vector QuantizationPyramid Vector Quantization
Pyramid Vector Quantization
ShahDhruv21
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
ShahDhruv21
 
JSP Directives
JSP DirectivesJSP Directives
JSP Directives
ShahDhruv21
 
WaterFall Model & Spiral Mode
WaterFall Model & Spiral ModeWaterFall Model & Spiral Mode
WaterFall Model & Spiral Mode
ShahDhruv21
 

More from ShahDhruv21 (12)

Semantic net in AI
Semantic net in AISemantic net in AI
Semantic net in AI
 
Error Detection & Error Correction Codes
Error Detection & Error Correction CodesError Detection & Error Correction Codes
Error Detection & Error Correction Codes
 
Secure Hash Algorithm (SHA)
Secure Hash Algorithm (SHA)Secure Hash Algorithm (SHA)
Secure Hash Algorithm (SHA)
 
Data Mining in Health Care
Data Mining in Health CareData Mining in Health Care
Data Mining in Health Care
 
Data Compression in Data mining and Business Intelligencs
Data Compression in Data mining and Business Intelligencs Data Compression in Data mining and Business Intelligencs
Data Compression in Data mining and Business Intelligencs
 
MongoDB installation,CRUD operation & JavaScript shell
MongoDB installation,CRUD operation & JavaScript shellMongoDB installation,CRUD operation & JavaScript shell
MongoDB installation,CRUD operation & JavaScript shell
 
2D Transformation
2D Transformation2D Transformation
2D Transformation
 
Interpreter
InterpreterInterpreter
Interpreter
 
Pyramid Vector Quantization
Pyramid Vector QuantizationPyramid Vector Quantization
Pyramid Vector Quantization
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
 
JSP Directives
JSP DirectivesJSP Directives
JSP Directives
 
WaterFall Model & Spiral Mode
WaterFall Model & Spiral ModeWaterFall Model & Spiral Mode
WaterFall Model & Spiral Mode
 

Recently uploaded

addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
Kamal Acharya
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
MuhammadTufail242431
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 

Recently uploaded (20)

addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
 

Topological Sorting

  • 1. TOPOLOGICAL SORT A. D. PATEL INSTITUTE OF TECHNOLOGY ANALYSIS AND DESIGN OF ALGORITHMS(2150703) : A.Y. 2018-19 DEPARTMENT OF INFORMATION TECHNOLOGY A D PATEL INSTITUTE OF TECHNOLOGY (ADIT) NEW VALLABH VIDYANAGAR, ANAND, GUJARAT GUIDED BY: PROF. DINESH J. PRAJAPATI (DEPT OF IT, ADIT) PREPARED BY: KUNAL R. KATHE(160010116021) DHRUV V. SHAH (160010116053) RUSHIL V. PATEL (160014116001) B.E. (IT) SEM - V 8TH OCTOBER, 2018
  • 2. 2 Outline  Introduction  Directed Acyclic Graph(DAG)  Algorithm  Example  Applications  References
  • 3. 3 Introduction WHAT IS TOPOLOGICAL SORT ?  For a directed acyclic graph G=(V,E)  A topological sort is an ordering of all of G’s vertices  v1, v2, v3,….,vn such that …  Vertex u comes before vertex v if edge (u,v) belongs to G  So,formally for every egde (vi,vk) in E ,i<k
  • 4. 4 Contd... Definition: A topological sort or topological ordering of a directed ayclic graph is a linear ordering of its vertices such that for every directed edge (u,v) from vertex u to v, u comes before v in the ordering.
  • 5. 5 Contd... 0 1 5 2 4 3 For example, a topological sorting of the given graph is “5 4 2 3 1 0”. There can be more then one topological sorting for a graph. For example , another topological sorting for the graph is “4 5 2 3 1 0”.The first vertex in topological sorting is always a vertex with in-degree as “0” ( a vertex with no incoming edges).  So, the Topological Sorting is NOT UNIQUE.  Also it can only be applied to Directed Acyclic Graphs(DAG).
  • 6. 6 Directed Acyclic Graph A directed acyclic graph is an acyclic graph that has a direction as well as a lack of cycles. 1 2 4 3 5 7 6 Vertices Set: {1,2,3,4,5,6,7} Edge Set: {(1,2),(1,3),(2,4), (2,5),(3,6),(4,7), (5,7),(6,7)} A directed acyclic graph has a topological ordering. This means that the nodes are ordered so that the starting node has a lower value than the ending node.
  • 9. 9 Example 1 2 43 5 6 7 Identify nodes having in degree ‘0’ Select a node and delete it with its edges then add node to output Select Node : 1 Output : 1
  • 10. 10 Contd… 2 43 5 6 7 Identify nodes having in degree ‘0’ Select a node and delete it with its edges then add node to output Select Node : 2 Output : 1 2
  • 11. 11 Contd… 43 5 6 7 Identify nodes having in degree ‘0’ Select a node and delete it with its edges then add node to output Select Node : 5 Output : 1 2 5
  • 12. 12 Contd… 43 6 7 Identify nodes having in degree ‘0’ Select a node and delete it with its edges then add node to output Select Node : 4 Output : 1 2 5 4
  • 13. 13 Contd… 3 6 7 Identify nodes having in degree ‘0’ Select a node and delete it with its edges then add node to output Select Node : 3 Output : 1 2 5 4 3
  • 14. 14 Contd… 6 7 Identify nodes having in degree ‘0’ Select a node and delete it with its edges then add node to output Select Node : 6 Output : 1 2 5 4 3 6 Select Node : 7 7
  • 15. 15 Applications  1] Build Systems :  We have various IDE’s like Ecllipse , Netbeans etc. We have to build a project which has many libraries dependent on each  other then IDE uses Topological Sort to decide which library to  include or build first.  2] Advanced-Packaging Tool(apt-get) :  In Linux apt-get is used to install softwares in the system. The command  “apt-get install VLC” is used. It is the way in Linux to install and remove  softwares.
  • 16. 16 Contd...  3] Task Scheduling :  Topological Sort is helpful in scheduling interdependent task to know which rask should proceed which one.  4] Pre- Requisite Problems:  We often come across situations where we need to finish one job in order to  proceed the next one. For ex, In University structure, we need to complete  basic Algorithm course to study an Advance Algorithm course. So, there  exist a pre- requisite and we can know this by doing a topological sort on all.
  • 18. 18