tsort
Brian Hicks, September 25, 2023
On the command line, you can use tsort
to sort a graph into a list (a topological ordering.) Say you have this chart showing what you need to get dressed:
You can write all those arrows down in a file as dependencies (in order of "X blocks Y," for example "Shirt blocks Tie," "Socks block Shoes.")
Shirt Tie
Undershirt Shirt
Shirt Belt
Pants Belt
Underwear Pants
Socks Shoes
Pants Shoes
If you pass that to tsort
you get this, one order in which you could put on clothes to get dressed:
Socks
Undershirt
Underwear
Shirt
Pants
Tie
Shoes
Belt
It kinda suggests lanes of parallelism, too. For example, you could hypothetically put socks, undershirt, and underwear at the same time. Granted, you'd have to have some machine like in Wallace and Gromit in The Wrong Trousers, but that turned out so well for them! 😆
On a more serious note, I've used this to order tasks in projects in Linear. Combined with blocker relationships, it makes it clear to everyone which tasks should go first.