An Activity Diagram is a behavioral UML diagram used to represent workflows, processes, and the sequence of activities within a system. It shows how actions are connected and how control flows from one activity to another.
- Illustrates sequential and concurrent activities, along with decision paths and control flow.
- Starts with an initial node and ends with a final node, helping model system behavior over time.
Example: An Online Shopping System activity diagram showing steps such as Browse Products -> Add to Cart -> Make Payment -> Order Confirmation.
Uses of Activity Diagram
Activity diagrams are used to visualize workflows, processes, and the dynamic behavior of a system.
Modeling Workflows or Processes
Used to represent business processes and the sequence of activities in a system.
- Visualizes the flow of tasks and operations.
- Helps understand process execution step by step.
Concurrent or Parallel Processing
Shows activities that occur simultaneously within a system.
- Represents parallel execution of tasks.
- Helps analyze concurrent workflows.
Understanding Dynamic Behavior
Illustrates how a system responds to events and changes over time.
- Shows movement between activities and states.
- Helps understand system behavior.
Clarifying Complex Logic
Simplifies processes involving multiple decisions and outcomes.
- Represents branching and conditional flows.
- Makes complex logic easier to understand.
System Design and Analysis
Supports the design and analysis of software systems.
- Helps developers understand system interactions.
- Improves communication among stakeholders.
Describing Use Cases
Represents the flow of actions within a use case.
- Shows interactions between system components.
- Helps visualize use case execution.
Activity Diagram Notations

1. Initial State
The starting state before an activity takes place is depicted using the initial state.

A process can have only one initial state unless we are depicting nested activities. We use a black filled circle to depict the initial state of a system.
Example: Here the initial state of the system before the application is opened.
.jpg)
2. Action or Activity State
An activity represents execution of an action on objects or by objects. We represent an activity using a rectangle with rounded corners. Basically any action or event that takes place is represented using an activity.

Example: Consider the previous example of opening an application, opening the application is an activity state in the activity diagram.

3. Action Flow or Control flows
Action flows or Control flows are also referred to as paths and edges. They are used to show the transition from one activity state to another activity state.

An activity state can have multiple incoming and outgoing action flows. We use a line with an arrow head to depict a Control Flow. If there is a constraint to be adhered to while making the transition it is mentioned on the arrow.
Example: Here both the states transit into one final state using action flow symbols i.e. arrows.

4. Decision node and Branching
When we need to make a decision before deciding the flow of control, we use the decision node. The outgoing arrows from the decision node can be labelled with conditions or guard expressions. It always includes two or more output arrows.

Example: We apply the conditions on input number to display the result :
- If number is odd then display the number.
- If number if even then display the error.
5. Guard
A Guard refers to a statement written next to a decision node on an arrow sometimes within square brackets.

The statement must be true for the control to shift along a particular direction. Guards help us know the constraints and conditions which determine the flow of a process.
6. Fork
A Fork Node is used to split a workflow into multiple parallel activities that execute simultaneously. No decision is made before the split, and all resulting activities must be performed concurrently. It is represented by a solid rectangular bar with one incoming arrow and multiple outgoing arrows.

Example: In the example below, the activity of making coffee can be split into two concurrent activities and hence we use the fork notation.
7. Join
Join nodes are used to support concurrent activities converging into one. For join notations we have two or more incoming edges and one outgoing edge.

Example: When both activities i.e. steaming the milk and adding coffee get completed, we converge them into one final activity.

8. Merge or Merge Event
Scenarios arise when activities which are not being executed concurrently have to be merged. We use the merge notation for such scenarios. We can merge two or more activities into one if the control proceeds onto the next activity irrespective of the path chosen.

Example: In the diagram below: we can't have both sides executing concurrently, but they finally merge into one. A number can't be both odd and even at the same time.
.jpg)
9. Swimlanes
Swimlanes are used to group related activities into rows or columns within an activity diagram. They improve organization and clarity by separating activities based on roles, responsibilities, or processes. Although optional, they are recommended because they make complex workflows easier to understand and manage.

We use a rectangular column to represent a swimlane as shown in the figure above.
Example: Here different set of activities are executed based on if the number is odd or even. These activities are grouped into a swimlane.

10. Time Event
This refers to an event that stops the flow for a time; an hourglass depicts it. We can have a scenario where an event takes some time to completed.

Example: Let us assume that the processing of an image takes a lot of time. Then it can be represented as shown below.

11. Final State or End State
The state which the system reaches when a particular process or activity ends is known as a Final State or End State. We use a filled circle within a circle notation to represent the final state in a state machine diagram. A system or a process can have multiple final states.

Draw an Activity Diagram in UML

The steps of how to draw the Activity Diagram in UML are:
Step 1: Identify the Initial State and Final States
Determine where the process starts and where it ends.
- Identify the starting point (initial state) of the workflow.
- Define the final state(s) that represent process completion.
Step 2: Identify the Intermediate Activities Needed
List all activities required to move from the initial state to the final state.
- Identify the tasks or actions performed during the process.
- Arrange activities in the order they are executed.
Step 3: Identify the Conditions or Constraints
Determine the conditions that control the flow between activities.
- Identify events or rules that trigger transitions.
- Define any constraints that affect process execution.
Step 4: Draw the Diagram with Appropriate Notations
Create the activity diagram using standard UML symbols and notations.
- Represent activities, states, and transitions visually.
- Ensure the workflow is clear and easy to understand.
Differences between an Activity diagram and a Flowchart
An activity diagram is very similar to a flowchart. So let us understand if activity diagrams or flowcharts are any different.
Flow Chart
An algorithm is like a set of clear instructions to solve a problem, and a flowchart is a picture that shows those instructions.
- When we're writing computer programs, a flowchart helps us map out the steps of the algorithm to solve the problem.
- Non programmers use Flow charts to model workflows.
- We can call a flowchart a primitive version of an activity diagram.
- Business processes where decision making is involved is expressed using a flow chart.
Example: A manufacturer uses a flow chart to explain and illustrate how a particular product is manufactured.
| Flowchart | Activity Diagram |
|---|---|
| Represents the step-by-step flow of a process or algorithm | Represents the flow of activities and actions in a system |
| Used mainly for procedural or algorithmic logic | Used to model workflows and business processes |
| Focuses on control flow using symbols like start, process, decision | Focuses on activities, decisions, parallel flows, and transitions |
| Simple and easy to understand | More expressive and detailed than flowcharts |
| Commonly used in programming and problem-solving | Commonly used in UML for system and process modeling |
| Does not support concurrency well | Supports parallel and concurrent activities |
Do we need to use both the diagrams and the textual documentation?
Let's understand this with the help of an example:
- Different individuals have different preferences in which they understand something.
- To understand a concept, some people might prefer a written tutorial with images while others would prefer a video lecture.
- So we generally use both the diagram and the textual documentation to make our system description as clear as possible.