Activity diagrams: decision and merge nodes

Activity diagrams: decision and merge nodes

puml.online

简介 / 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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
@startuml
skinparam activity {
BackgroundColor #Fog
DiamondBackgroundColor #LightYellow
DiamondBorderColor #Orange
}
|Client|
start
:输入用户名和密码;
:提交登录请求;
if (凭证有效?) then (是)
:显示仪表盘;
stop
else (否)
:显示错误提示;
:返回登录页;
endif
stop
@enduml

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
2
3
4
5
6
7
8
flowchart TD
A[输入用户名和密码] --> B[提交登录请求]
B --> C{凭证有效?}
C -->|是| D[显示仪表盘]
C -->|否| E[显示错误提示]
E --> F[返回登录页]
D --> G[结束]
F --> G

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.
On this page
Activity diagrams: decision and merge nodes