Input: 𝐷 : Sequence diagram in XMI form     // 𝐷 is the main fragment
Output:G: scenario graph in the form 𝐴 , 𝐸 , 𝑖 𝑛 , 𝐹
1:Create initial node 𝑖 𝑛 ;
2: 𝑥 = 𝑃 𝑟 𝑜 𝑐 𝑒 𝑠 𝑠 𝐹 𝑟 𝑎 𝑔 𝑚 𝑒 𝑛 𝑡 ( 𝐷 , 𝑖 𝑛 )     // Process the main
  fragment with 𝑓 𝑟 𝑎 𝑔 𝑚 𝑒 𝑛 𝑡 𝐼 𝑑 = 𝐷
3: if 𝑥 𝑓 𝑖 𝑛 𝑎 𝑙 𝑛 𝑜 𝑑 𝑒 then
4:   Create final node 𝑓 𝑛 𝐹 ;
5:   Connect edge from 𝑥 𝑡 𝑜 𝑓 𝑛 ;
6:end if
7:return 𝐺 with entry node 𝑖 𝑛 𝐴 and exit node 𝑓 𝑛 𝐹 ;
8:stop
Algorithm—The scenario graph generation algorithm
Procedure 1: Function Create Scenario Graph.