diff --git a/src/graph/topological-sort.md b/src/graph/topological-sort.md index 97da9a0ed..f8e8e9218 100644 --- a/src/graph/topological-sort.md +++ b/src/graph/topological-sort.md @@ -26,14 +26,14 @@ The example graph also has multiple topological orders, a second topological ord A Topological order may **not exist** at all. It only exists, if the directed graph contains no cycles. -Otherwise because there is a contradiction: if there is a cycle containing the vertices $a$ and $b$, then $a$ needs to have a smaller index than $b$ (since you can reach $b$ from $a$) and also a bigger one (as you can reach $a$ from $b$). +Otherwise, there is a contradiction: if there is a cycle containing the vertices $a$ and $b$, then $a$ needs to have a smaller index than $b$ (since you can reach $b$ from $a$) and also a bigger one (as you can reach $a$ from $b$). The algorithm described in this article also shows by construction, that every acyclic directed graph contains at least one topological order. -A common problem in which topological sorting occurs is the following. There are $n$ variables with unknown values. For some variables we know that one of them is less than the other. You have to check whether these constraints are contradictory, and if not, output the variables in ascending order (if several answers are possible, output any of them). It is easy to notice that this is exactly the problem of finding topological order of a graph with $n$ vertices. +A common problem in which topological sorting occurs is the following. There are $n$ variables with unknown values. For some variables, we know that one of them is less than the other. You have to check whether these constraints are contradictory, and if not, output the variables in ascending order (if several answers are possible, output any of them). It is easy to notice that this is exactly the problem of finding the topological order of a graph with $n$ vertices. ## The Algorithm -To solve this problem we will use [depth-first search](depth-first-search.md). +To solve this problem, we will use [depth-first search](depth-first-search.md). Let's assume that the graph is acyclic. What does the depth-first search do?
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: