This repository has been archived on 2022-06-22. You can view files and clone it, but cannot push or open issues or pull requests.
usaco-guide/content/5_Gold/TopoSort.md
2020-06-15 21:06:49 -04:00

34 lines
No EOL
1.1 KiB
Markdown

---
id: toposort
title: "Topological Sort"
author: Benjamin Qi
prerequisites:
-
- Gold - Breadth First Search
---
A [topological sort](https://en.wikipedia.org/wiki/Topological_sorting) of a directed graph is a linear ordering of its vertices such that for every directed edge $u\to v$ from vertex $u$ to vertex $v$, $u$ comes before $v$ in the ordering.
## Example Problems
- [CSES Course Schedule](https://cses.fi/problemset/task/1679)
- [CSES Longest Flight Route](https://cses.fi/problemset/task/1680)
- [CSES Game Routes](https://cses.fi/problemset/task/1681)
## Tutorial
- CPH 16.1, 16.2
- DFS
- [cp-algorithms](https://cp-algorithms.com/graph/topological-sort.html)
- DFS
- [CSAcademy](https://csacademy.com/lesson/topological_sorting)
- both BFS, DFS
## Problems
- USACO Gold
- [Timeline](http://www.usaco.org/index.php?page=viewproblem2&cpid=1017)
- [Milking Order](http://www.usaco.org/index.php?page=viewproblem2&cpid=838)
- Other
- [Minimal Labels](http://codeforces.com/contest/825/problem/E) [](53)
- [Quantum](https://open.kattis.com/contests/acpc17open/problems/quantumsuperposition) [](84)