•Download as PPT, PDF•

0 likes•15 views

Ed

Report

Share

Report

Share

Topological sorting

Topological sorting

Topological Sort and Shortest Path in Directed Acyclic Graph with Single Source

Topological Sort and Shortest Path in Directed Acyclic Graph with Single Source

Introduction to graphs

Introduction to graphs

Graphs

Graphs

Unit ix graph

Unit ix graph

Unit VI - Graphs.ppt

Unit VI - Graphs.ppt

Algorithms of graph

Algorithms of graph

LEC 12-DSALGO-GRAPHS(final12).pdf

LEC 12-DSALGO-GRAPHS(final12).pdf

Graph 1

Graph 1

Data structure and algorithm using java

Data structure and algorithm using java

DSJ_Unit I & II.pdf

DSJ_Unit I & II.pdf

introduction to data structures and types

introduction to data structures and types

Lecture13

Lecture13

Lecture 16 - Dijkstra's Algorithm.pdf

Lecture 16 - Dijkstra's Algorithm.pdf

Solid modeling

Solid modeling

6. Graphs

6. Graphs

Topological Sorting (Decrease and Conquer)

Topological Sorting (Decrease and Conquer)

Queue ADT for data structure for computer

Queue ADT for data structure for computer

Lecture 9-online

Lecture 9-online

Week2-stacks-queues.pptx

Week2-stacks-queues.pptx

Student Voting Application for Election – Using SMS (1).pptx

Student Voting Application for Election – Using SMS (1).pptx

Project Management (2).pdf

Project Management (2).pdf

pca.ppt

pca.ppt

The Product and Process(1).pdf

The Product and Process(1).pdf

Lecture1_jps (1).ppt

Lecture1_jps (1).ppt

2 semai.pptx

2 semai.pptx

artificialintelligencea-200326090832.pdf

artificialintelligencea-200326090832.pdf

Software Project Risks Management (1).pdf

Software Project Risks Management (1).pdf

Introduction (1).pdf

Introduction (1).pdf

Unit 3 (1) (1).pdf

Unit 3 (1) (1).pdf

Unit 1 (1).pdf

Unit 1 (1).pdf

Strassen.ppt

Strassen.ppt

Notion of Algorithms.pdf

Notion of Algorithms.pdf

11_Automated_Testing.ppt

11_Automated_Testing.ppt

OS-Final-Transform-Manual-Testing-Processes-to-incorporate-Automatio....pptx

OS-Final-Transform-Manual-Testing-Processes-to-incorporate-Automatio....pptx

Project Management.pdf

Project Management.pdf

PP

PP

chapter2.ppt

chapter2.ppt

machinelearningengineeringslideshare-160909192132 (1).pdf

machinelearningengineeringslideshare-160909192132 (1).pdf

intelligent agent (1).pptx

intelligent agent (1).pptx

https://app.box.com/s/m9ehjx5owsaox9ykvb9qg3csa8a0jnoxTỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...

TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection

https://app.box.com/s/xplac2t6bphx6pe1mofyfj0fvrjx1f3i24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...

24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection

https://app.box.com/s/h5mhqoyabotgw05s0df0ltw3e39pgnmyTỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...

TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection

Observing-Correct-Grammar-in-Making-Definitions.pptx

Observing-Correct-Grammar-in-Making-Definitions.pptx

UChicago CMSC 23320 - The Best Commit Messages of 2024

UChicago CMSC 23320 - The Best Commit Messages of 2024

Pharmaceutical Biotechnology VI semester.pdf

Pharmaceutical Biotechnology VI semester.pdf

Personalisation of Education by AI and Big Data - Lourdes Guàrdia

Personalisation of Education by AI and Big Data - Lourdes Guàrdia

What is 3 Way Matching Process in Odoo 17.pptx

What is 3 Way Matching Process in Odoo 17.pptx

When Quality Assurance Meets Innovation in Higher Education - Report launch w...

When Quality Assurance Meets Innovation in Higher Education - Report launch w...

AIM of Education-Teachers Training-2024.ppt

AIM of Education-Teachers Training-2024.ppt

Andreas Schleicher presents at the launch of What does child empowerment mean...

Andreas Schleicher presents at the launch of What does child empowerment mean...

SPLICE Working Group:Reusable Code Examples

SPLICE Working Group:Reusable Code Examples

TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...

TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...

DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM

DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM

PS-Policies-on-Enrolment-Transfer-of-Docs-Checking-of-School-Forms-and-SF10-a...

PS-Policies-on-Enrolment-Transfer-of-Docs-Checking-of-School-Forms-and-SF10-a...

Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships

Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships

24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...

24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...

Graduate Outcomes Presentation Slides - English (v3).pptx

Graduate Outcomes Presentation Slides - English (v3).pptx

Rich Dad Poor Dad ( PDFDrive.com )--.pdf

Rich Dad Poor Dad ( PDFDrive.com )--.pdf

TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...

TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...

Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx

Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx

FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf

FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf

UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf

UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf

- 1. Topological Sort • Introduction. • Definition of Topological Sort. • Topological Sort is Not Unique. • Topological Sort Algorithm. • An Example. • Implementation. • Review Questions.
- 2. Introduction • There are many problems involving a set of tasks in which some of the tasks must be done before others. • For example, consider the problem of taking a course only after taking its prerequisites. • Is there any systematic way of linearly arranging the courses in the order that they should be taken? Yes! - Topological sort.
- 3. Definition of Topological Sort • Topological sort is a method of arranging the vertices in a directed acyclic graph (DAG), as a sequence, such that no vertex appear in the sequence before its predecessor. • The graph in (a) can be topologically sorted as in (b) (a) (b)
- 4. Topological Sort is not unique • Topological sort is not unique. • The following are all topological sort of the graph below: s1 = {a, b, c, d, e, f, g, h, i} s2 = {a, c, b, f, e, d, h, g, i} s3 = {a, b, d, c, e, g, f, h, i} s4 = {a, c, f, b, e, h, d, g, i} etc.
- 5. Topological Sort Algorithm • One way to find a topological sort is to consider in-degrees of the vertices. • The first vertex must have in-degree zero -- every DAG must have at least one vertex with in-degree zero. • The Topological sort algorithm is: int topologicalOrderTraversal( ){ int numVisitedVertices = 0; while(there are more vertices to be visited){ if(there is no vertex with in-degree 0) break; else{ select a vertex v that has in-degree 0; visit v; numVisitedVertices++; delete v and all its emanating edges; } } return numVisitedVertices; }
- 6. Topological Sort Example • Demonstrating Topological Sort. A F B G C H D I E J 1 2 3 0 2 1 0 2 2 0 D G A B F H J E I C
- 7. Implementation of Topological Sort • The algorithm is implemented as a traversal method that visits the vertices in a topological sort order. • An array of length |V| is used to record the in-degrees of the vertices. Hence no need to remove vertices or edges. • A priority queue is used to keep track of vertices with in-degree zero that are not yet visited. public int topologicalOrderTraversal(Visitor visitor){ int numVerticesVisited = 0; int[] inDegree = new int[numberOfVertices]; for(int i = 0; i < numberOfVertices; i++) inDegree[i] = 0; Iterator p = getEdges(); while (p.hasNext()) { Edge edge = (Edge) p.next(); Vertex to = edge.getToVertex(); inDegree[getIndex(to)]++; }
- 8. Implementation of Topological Sort BinaryHeap queue = new BinaryHeap(numberOfVertices); p = getVertices(); while(p.hasNext()){ Vertex v = (Vertex)p.next(); if(inDegree[getIndex(v)] == 0) queue.enqueue(v); } while(!queue.isEmpty() && !visitor.isDone()){ Vertex v = (Vertex)queue.dequeueMin(); visitor.visit(v); numVerticesVisited++; p = v.getSuccessors(); while (p.hasNext()){ Vertex to = (Vertex) p.next(); if(--inDegree[getIndex(to)] == 0) queue.enqueue(to); } } return numVerticesVisited; }
- 9. Review Questions 1. List the order in which the nodes of the directed graph GB are visited by topological order traversal that starts from vertex a. 2. What kind of DAG has a unique topological sort? 3. Generate a directed graph using the required courses for your major. Now apply topological sort on the directed graph you obtained.