in my work with explicit topological ordering under the presence of loops, i figured this out:

topological ordering is the same as partial ordering. so for two nodes `{a,b}`, when `a -> b`, then `a < b`.

with cyclical dependencies, this no longer makes sense under a linear partial order. if `a -> b, b -> a`, then `a < b < a`.

we need cyclic partial ordering, which is based on cyclic order (https://en.wikipedia.org/wiki/Cyclic_order). now we can express this after all, as `[a, b, a]`.

#devlog

Cyclic order - Wikipedia

tarjan's SCC algo is typically used to construct a DAG from a cyclical graph, but its strongly connected components are soup.

as an example, the dependency graph below counts as a single SCC even though we can clearly see it has a substructure, which suggests that {2,5,6,7} should be iterated in a subloop.

the question now is whether ternary relation terms, or something similar, could allow us to describe subcycles.

#devlog

LRDL presently solves the problem by requiring that the user picks explicit backedges (using `cue` for insertion rather than `then`), which turns the entire cyclical graph into a spanning DAG.

it also requires that we put edges connecting {2,5,6,7} in a dedicated `fold` block which guarantees evaluating this subgraph will reach a fixed point before the parent continues.

this makes execution order "reasonable", but is it the only good solution?

#devlog #LRDL

@lritter but topologically both loops are the same size, I'd say the natural clustering is to have both loops be their own cluster and then make them both children of 2. In that way the 2 is some sort of "special highly connected node". There must be some good name for that, I know in epidemiology they treat highly connected nodes in a special way for example.
@winden in LRDL, edges can have side effects. so there is good reason for saying "i definitely want 1->2 to always run first"
@lritter AFAIK, you build the strongly connected components with an algorithm like Tarjan, which gives you the topological tree of cycles as a byproduct. Tarjan is one of the most beautiful Algos out there. 😍

@yesbait been there done that, and it's insufficient. strongly connected components are soup.

the graph below counts as one single SCC even though we can clearly see it has a substructure. no SCC algorithm can catch this relationship.

@lritter So, once you have an SCC, you are looking for all circular orders within it. Correct?
I am wondering if this could be computed as possible side-effect while the algo traverses the tree.
@yesbait another complication is that there is no canonical way to nest loops just from the graph description. the designer has to encode a preference somehow.