Edge directionality: directed, bidirectional and edge groups
Every relationship built so far in this series has been an ordinary directed edge: an equation evaluated once, contributing to one side only. That's the right default for most models, but not the only shape a relationship can take, and the choice between them isn't just a labeling preference. For one specific kind of equation, it changes the actual numbers a run produces.
The example below stays deliberately small to make that visible: two nodes, A and B, each with a single state called Value starting at 0, connected by one relationship whose entire equation is the constant 0.01. That equation is worth noticing on its own terms: it doesn't reference A or B at all, it's the same number regardless of which node is which.
The default: directed
A freshly created edge is always directed, source to target. There's no directionality choice in the edge builder itself: setting anything else means editing the edge afterward.
Running this model for 10 seconds produces exactly what a directed edge promises: the equation contributes only to its declared output, here target.value, and nothing else in the model moves.
Making it bidirectional
Editing the same edge and switching its directionality to Bidirectional keeps the same source and target (that choice was made once, when the edge was drawn), but changes how the engine uses them: the equation is still evaluated once, then applied to both sides, negated on the far one.
Closing the results and running the identical model again, unchanged except for that one dropdown, produces a different result:
This is exactly correct for a genuine conserved quantity, provided the equation is anti-symmetric under swapping source and target: a real function of sourceX - targetX, the way heat, mass or current transfer always is. Swap which node is source and the formula's sign flips too, but the physical result doesn't change.
A bare constant is the sharp counterexample, and it's why this example uses one. 0.01 doesn't reference source or target at all, so it isn't anti-symmetric. The ±0.1 split above wasn't computed from anything physical: it was decided entirely by which node happened to get labeled target when the edge was drawn. Bidirectional is the right tool for a real flux equation, not a substitute for "connects two nodes."
The edge-group alternative
"Subsystems and edge groups" covers building an edge group. What's worth knowing here is how its mesh actually behaves, because it isn't a bidirectional edge under another name.
An edge group never uses one bidirectional edge per pair. Instead, for every pair of members, it builds two ordinary directed edges, one each way, both carrying the identical equation. Each is evaluated independently, with its own source and target, and lands on its own target with no mirroring or sign flip involved. For the equation in this example, that means A → B contributes +0.01/s to B, and B → A independently contributes +0.01/s to A: both nodes end at +0.1, not the ±0.1 split a bidirectional edge produced.
For a genuinely anti-symmetric flux equation, this reduces to the same numbers a bidirectional edge would give: k · (sourceX - targetX) evaluated as A → B gives k(A-B), and evaluated as B → A gives k(B-A), the exact negative of the first. Nothing is lost for real physics. This shape exists because a group has no single user-chosen source and target for a given pair the way a hand-drawn edge does, so an arbitrary role assignment across a larger mesh would be unavoidable with only one edge per pair. Two independent directed edges sidestep that question instead of answering it arbitrarily.
That also means a two-member edge group is not interchangeable with a bidirectional edge, even though both connect the same two nodes. For an anti-symmetric equation the two happen to agree numerically, which is exactly why this rarely comes up in practice. For anything that isn't, a bare constant being the clearest case, they don't. Wanting real sign-flip, conserved-exchange behavior for exactly two nodes calls for an ordinary bidirectional edge, not a 2-member group.
Choosing between them
- A one-way contribution with no counter-effect on the other side: an ordinary directed edge.
- Exactly two nodes and a real conserved quantity flowing between them, equation written as
sourceX - targetX: an ordinary bidirectional edge, with source and target chosen deliberately. - The same interaction replicated across three or more nodes, or a two-node case authored the same way a larger mesh would be: an edge group, with the equation written the same anti-symmetric way across every pair.
Where to go from here
This closes a gap left open since "Getting started," which only ever needed the directed default. From here, "Subsystems and edge groups" covers building the mesh described above, and "Running a simulation" covers everything this page did with Run and Close and edit in more depth.
Follow Konjugate on LinkedIn for updates.
Comments
Post a Comment