Skip to content

Connection Rules

The canvas refuses a connection that would touch a node that takes none, duplicate an edge, join a node to itself or - when asked to - close a cycle, and every refusal has a reason. The same rules answer from code: CheckConnection on the canvas while a connection is dragged, and BlowConnectionRules.Check with no canvas at all.

A
0 in · 1 out
B
1 in · 1 out
C
1 in · 0 out
Locked
takes no connections
bit Blow

Try it

  • Drag from A's output (right): B's input is red because A already feeds B, A's own input is red because a node may not connect to itself, Locked's is red because it takes no connections, and C's is green. The list under the canvas names each reason.
  • Untick Prevent duplicate edges and drag A to B again: a second, parallel edge is made.
  • Tick Allow self-connections: A's own input turns green, and a release there draws a loop.
  • Tick Prevent cycles and drag from C's output to A's input: refused, because A already leads to C through B. A self-connection is a cycle too, so this also overrides Allow self-connections.
  • Try to drag from Locked's handles: nothing starts. The table under the canvas checks every output against every input with the same rules, without a drag, and changes as you tick the boxes, connect, or delete an edge (select it, then Delete). Reset edges starts over.

How it works

  • The rules run in a fixed order and the first that fails is the BlowConnectionRejection: NotConnectable (a node with Connectable = false, or hidden), SameHandleType (in strict mode), SelfConnection, Duplicate, the ports' data types and limits, Cycle, and last your own rules (RejectedByRule).
  • PreventDuplicateEdges is on by default; AllowSelfConnections is off, and even on it needs two different handles; PreventCycles is off. ConnectionRadius="30" snaps a release within 30 screen pixels to the nearest handle that accepts it.
  • CheckConnection(nodeId, handleId, type) is the canvas's verdict on one handle for the connection being dragged - every rule, the handles' own included - and DescribeConnection the BlowConnection completing there would make. Outside a drag, CheckConnection answers NotConnectable; this page asks it on each OnConnectionChange.
  • CanStartConnection(nodeId, handleId, type) is false for Locked, which is why its handles ignore presses; CountConnections(nodeId, type, handleId) gives the counts under each node.
  • BlowConnectionRules.Check(nodes, edges, connection, policy) is the same decision as a pure function, for a server, a test or an import; here the BlowConnectionPolicy (PreventDuplicates, AllowSelfConnections, PreventCycles, Mode, TypeCompatibility, IsValidConnection) mirrors the checkboxes. It knows nothing of rules written on a BlowHandle, and BlowConnectionRules.Begin binds it to one starting handle to check many candidates cheaply.
An unhandled error has occurred. Reload 🗙