Search code examples
umlactivity-diagramplantuml

How to reference earlier activity in PlantUML UML Activity Diagram


I am trying to make an activity diagram with PlantUML (new beta syntax).

So far I came up with (simplified):

@startuml
start
:A;
if (Q1) then (yes)
  :B;
  
  if (Q2) then (yes)
    :D;
  else (no)
    :E;
  endif
  
else (no)
  :C;
endif
stop
@enduml

plant uml diagram

It means, do A, if yes on first question do B otherwise C. After B ask question 2, if yes do D if no do E.

Instead of pointing to E when the answer on question 2 is no I want to go to activity C, however I don't know how to reference it. If I put :C; there (instead of :E; it is just interpreted as a new activity (however it's flow should continue from C there). I assume there is a way to draw a flow like this with PlantUML but I don't see it yet.

What would be the best way to reference an already defined activity?


Solution

  • My current solution (been using plantUML for a week or so) is something like this:

    @startuml
    start
    :A;
    if (Q1) then (yes)
      :B;
    
      if (Q2) then (yes)
        :D;
      else (no)
        :E;
        :call C>
      endif
    else (no)
      :call C>
    endif
    stop
    partition C {
      :do 1st C thing;
      :do 2nd C thing;
    }
    @enduml
    

    Plant uml diagram