Topological Sort
socks 0
underwear 0
shirt 0
trousers 1
belt 2
shoes 2
jacket 2
queue · FIFO
empty
take from the front
Getting dressed: some things must come before others. The arrow under → trousers means underwear goes on first. The number on each node counts how many things still block it — its in-degree.
step 01/17
- just discovered
- visited
- found it
- waiting in the queue / stack