The library provides several specialized state types to represent different structural patterns:
- Simple State: A standard state with an ID and a label.
state = State("state_id", "State Label") - Start State: Represents the entry point
[*].
start = Start() - End State: Represents the exit point
[*].
end = End() - Composite State: A state that contains its own internal sub-states and transitions.
composite = Composite("id", "Label", sub_states=[...], direction=...) - Concurrent State: A state containing parallel sub-groups that run simultaneously.
concurrent = Concurrent("id", "Label", sub_groups=[(group1, []), (group2, [])])
from mermaid.statediagram import State, Start, End, Composite, Concurrent, Direction
# Simple
state = State("s1", "Simple")
# Start/End
start = Start()
end = End()
# Composite
sub_states = [State("sub1", "Sub 1"), State("sub2", "Sub 2")]
composite = Composite("comp", "Composite", sub_states=sub_states, direction=Direction.TOP_TO_BOTTOM)
# Concurrent
g1 = [State("p1", "P1")]
g2 = [State("p2", "P2")]
concurrent = Concurrent("par", "Parallel", sub_groups=[(g1, []), (g2, [])])