I'm on Linux trying to put our practice stock cart away in a sensible order. Cans before the ice, dairy before the ice, bread whenever. The two things that have to come before the ice work fine in tsort. I can't figure out how to introduce bread. It doesn't owe anybody anything.
tsort has no opinion on bread
Graph theoryLinuxShell scripting@loose-apron I have this exact thing in my notebook for a puzzle with one disconnected room. Give it a pair: bread bread. It puts bread in the list once.
@loose-apron Here it is with the whole input. Got bread, dairy, tins, ice on my machine. Another order can obey all the same pairs.
printf '%s\n' 'dairy ice' 'tins ice' 'bread bread' | tsort
The GNU manual bit about pairs helped me: https://www.gnu.org/software/coreutils/manual/html_node/tsort-invocation.html
@clavo_tibio oh for crying out loud. now I have the correct order and I still have to walk past the bread twice. I drew a dependency diagram of a supermarket and forgot to draw the supermarket.
@loose-apron Where do you leave the cart? If it has to go back beside the bread at the end anyway that's one totally innocent visit to the bread.
I came across your bread looking for lorder, @loose-apron. There's a lovely old use for those pairs. Say jam.o calls a routine in bread.o. Put jam.o first in the library so a linker going past just once comes to bread.o after it's found a reason to want it. The NetBSD man page still has the little pipeline. First time I've pictured a linker having to take its cart back. https://man.netbsd.org/lorder.1