Activity diagrams: decision and merge nodes
简介 / Introduction
Activity diagrams model business processes in a system. The core elements are decision nodes (branching logic) and merge nodes (converging paths). Both are drawn as diamonds: a decision node picks a branch based on a condition, while a merge node brings multiple paths back together. This article uses the same login flow example in both PlantUML and Mermaid to compare syntax and rendering.
PlantUML 版
1 | @startuml |
PlantUML uses if (...) then (...) else (...) endif to express decision nodes; merge nodes are implied by endif. The |Client| swimlane syntax tracks the actor. Branch labels like (是) / (否) are written directly after then / else.
Mermaid 版
1 | flowchart TD |
Mermaid draws decision nodes with { } (diamond shape). Branch labels are placed on edges using |是| / |否| syntax. A merge node is simply two edges converging on the same target node — no explicit merge syntax required. Mermaid does not support swimlanes natively, but subgraph can approximate the effect.
对比 / Side-by-side
| Feature | PlantUML | Mermaid |
|---|---|---|
| Decision node syntax | if (...) then (...) else (...) endif |
{ } diamond node |
| Merge node | implicit via endif |
edges converge on same target node |
| Branch labels | (是) / (否) after then/else |
` |
| Swimlanes | |Actor| native support |
not supported, use subgraph instead |
| Start/end | start / stop keywords |
plain nodes, no explicit start/end |
小结 / Wrap-up
Decision and merge nodes are the basic building blocks of activity diagrams. PlantUML’s if/endif structure reads like code and scales well for deeply nested conditions. Mermaid’s { } nodes with edge labels are more visual and require less ceremony for straightforward flows. Both clearly express branching and convergence; pick based on your team’s toolchain and the diagram’s complexity.
- Title: Activity diagrams: decision and merge nodes
- Author: puml.online
- Created at : 2026-09-09 09:00:00
- Updated at : 2026-09-29 01:06:38
- Link: https://puml.online/blog/activity-diagram-decision-merge-en/
- License: This work is licensed under CC BY-NC-SA 4.0.