Two valid orders, one graph
transcript
Here is one valid build order. Here is another. Both are correct. How can that be?
Zero, one, two, four, three, five. Every arrow points forward. Zero, two, one, three, four, five. Every arrow points forward too. After step zero, steps one and two are both ready. Neither waits for the other. Either can go first. Need one fixed answer? Take the smallest ready step.
Keep the ready steps in a min heap. After zero, the heap holds one and two. Take one. Then two, three, four and five. The answer is the same every run.
Only one step is ready at a time. That happens with one long chain. Otherwise, ties give many orders. Each tie multiplies the choices. So most graphs have many orders. A rule for ties picks one.
Two ready steps mean two orders. A rule for ties fixes one. A min heap gives the smallest. Full breakdown in the lecture.