A topological sort is a linear ordering of nodes in a directed graph such that for every directed edge from node 'a' to node 'b', node 'a' comes before node 'b' in the ordering.
Key constraints and properties:
- Requirement: A directed graph has a topological sort if and only if it is acyclic (a Directed Acyclic Graph or DAG).
- Cycles: If a graph contains a cycle, a topological sort is impossible because no node in the cycle can precede all others.
- Uniqueness: Topological sorts are not necessarily unique; a single graph may have multiple valid topological orderings.