Topological Sort of a Directed Acyclic Graph

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

External

Internal

Overview

This is a very useful algorithm when a set of tasks that have precedence constraints between them need to be sequenced - executed in order. The topological sort can be done using Depth-First Search (DFS).

Straightforward Algorithm

We use the observation that a DAG must have one or more sink vertices. The algorithm starts with a sink vertex, assign its the larger label