Cycle detection: why the calculation stops, and how to find the loop
When two spreadsheet cells refer to each other you get a zero or a warning. Node graphs have the same failure. A cycle is a structural problem, and structure can be fixed where you can see it.
Three ways a cycle appears
First, a node referring to itself: wiring a node's output back into its own input by mistake.
Second, two nodes referring to each other. "Profit after cost" and "cost as a share of profit" wired together leave both undefined.
Third, three or more nodes closing a loop. A uses B, B uses C, C uses A, and none of them can start. This is the hardest to see by eye and the most common miss in a long graph.
| What you see | Likely cause | Fix |
|---|---|---|
| A few nodes have no value | A result wired back into an input | Cut one wire between the cycle nodes |
| A loaded file stops computing | JSON edited by hand | Read the marked cycle and delete that wire |
| A value computes as zero | Input port left empty | Click the port to connect (empty counts as 0) |
| A series looks flat | Rate input not connected | Wire a slider into the rate port |
| A node is never computed | Excluded by the sort | Check the "in cycle" row in the value table |
Refusing it before it exists
Before creating a wire, FlowSim checks whether the wire would let you walk from the target back to the source. If it would, the wire is not created and the app says so.
The check costs one graph walk per wire, so it is instant. The user can then wire freely under the guarantee that no cycle exists.
The same check runs when a wire is moved: between cutting and reconnecting there is no moment where a cycle can slip in.
When a loaded graph has a cycle
A JSON you did not build, or one edited by hand, can contain a cycle. FlowSim still loads it, but stops the computation and marks the nodes inside the loop.
The rest of the graph is still computed, because the part outside the cycle is still valid. The names of the cycle nodes appear in order, so you can see where to cut.
Fixing it means cutting one wire in the loop. Usually it is the wire that carries this period's result back into this period's input, so look for the wire whose direction you did not intend.
Not to be confused with iteration
A cycle is not the same as iteration. Iteration means using last period's value to get this period's value, which is exactly what a series node does. It looks self-referential but it moves along a time axis, so it is not a graph cycle.
The FlowSim series node takes a start value, a per-period addition and a rate, and produces one value per period. The repetition happens inside a single node, so the graph stays acyclic.
A → B → C → A # cycle: nobody can start
A → B → C # fine: one pass, C last
series(start, add, r) # repetition happens INSIDE one node
Design habits that avoid cycles
Keep the direction of calculation single. Start from source values (demand, rate, unit price), pass through derived values (totals, tax, cost), and end at results (net profit, balance).
If a result genuinely feeds back into a source value, one pass cannot solve it. Split time with a series node, or run a separate target-seeking loop outside the graph.
Questions
Can I deliberately create a cycle?
FlowSim will not create one. A loaded file with a cycle stops computation and is only marked, so you cannot read values from a cyclic state.
I found the cycle but do not know which wire to cut.
Read the node names in the cycle and look for the wire that carries a result back to an input. It is usually one wire running right to left.
Sources
Every calculation here can be reproduced with a template in the simulator.
Open the simulator