One function
order_layers in fasouto/termaid
The author described this change as “fix: keep all nodes when an orthogonal subgraph contains a cycle”. It counts as a record because the check below fails on the code as it stood at e88991c2d and passes on 81c69b2d7, with nothing else changed between the two runs.
Projectfasouto/termaid
Fix saved2026-06-11
Sharing licenceMIT · LICENSE
Change size+5 −3
What the code was meant to do, written into the code itself as a docstring
Order nodes within each layer using barycenter heuristic.
The change
| 67 | 67 | in_degree[succ] -= 1 | |
| 68 | 68 | if in_degree[succ] == 0: | |
| 69 | 69 | kahn_queue.append(succ) | |
| 70 | - | # Replace in-layer positions: find positions of sg nodes, fill with topo order | |
| 70 | + | # Replace in-layer positions: find positions of sg nodes, fill with topo order. | |
| 71 | + | # A cycle leaves topo incomplete; rewriting then duplicates | |
| 72 | + | # some nodes and drops others, so keep the original order. | |
| 71 | 73 | positions = [i for i, n in enumerate(layer) if n in internal] | |
| 72 | - | for idx, pos in enumerate(positions): | |
| 73 | - | if idx < len(topo): | |
| 74 | + | if len(topo) == len(positions): | |
| 75 | + | for idx, pos in enumerate(positions): | |
| 74 | 76 | layer[pos] = topo[idx] | |
| 75 | 77 | ||
| 76 | 78 | return layer_lists |
The check that tells the two apart
fail→pass·tests/test_layout.py::TestOrthogonalSubgraphOrdering::test_cyclic_subgraph_keeps_all_nodes
Check file tests/test_layout.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before ite88991c2df3e657899070548830e7571732650f5
Broken version dated2026-06-11
Moduletermaid.layout.layers
Units changedorder_layers
Fingerprint809ff463681bbc6f
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in fasouto/termaid
- 2026-06-11_position_children