Switch

Conditional branching node. Routes growth to different subgraphs based on attributes, thresholds, or mappings.

The Switch node gates growth flow, acting like an if/else statement for your graph.

  • Conditional Routing: Chooses between multiple input graphs based on conditions evaluated per internode.
  • State-Driven: Enables logic like "if age > 5, switch to flowering logic".
  • Adaptive: Allows recipes to react to their own attributes or environment.

Concept

Gating Logic Switch evaluates a list of conditions in order. The first condition that evaluates to true determines which input graph is executed for that specific internode. If no conditions match, the default path is taken.

Use Cases

  • Transitions: Bud → Shoot → Flower.
  • Environment: Grow tall in sun, grow wide in shade.
  • Variation: Randomly choose between different branch structures.

Inputs

  • Input 0 — Graph A Executed if the switch evaluates to False (or matches Condition 0).
  • Input 1 — Graph B Executed if the switch evaluates to True (or matches Condition 1).
  • Output — Graph The merged graph.

Parameters

Conditions A list of rules to evaluate.

  • Attribute: The attribute to read (e.g., age).
  • Condition: The operator (>, ==).
  • Threshold: The value to compare against (Float, Attribute, or Map).

Advanced

  • Snippet Condition: Inline VEX for complex logic (e.g., (@age > 5) && (@height < 2)).

Attributes

Switch consumes attributes for gating.

  • Common Inputs: age, u, generation, height, random.

Workflow

  1. Create two different growth subgraphs (e.g., "Leafy Branch" and "Bare Branch").
  2. Connect them to a Switch node.
  3. Set a condition (e.g., height > 10).
  4. Internodes below height 10 will use the first graph; those above will use the second.

NodeRelationship
GrowCreates the internodes that Switch routes
SplitUnconditional parallel branching
WrangleCreates attributes for Switch conditions