## 6 Composition of a BPMN Diagram
### Process Composition Based on Activity Graphs
In order to illustrate such a situation, let us present an example of two workflow logs, each consisting of two traces having four different activities (Formulae (6) and (7)):  
\[W_{1}=\{ABCD,ACBD\}, \tag{6}\]  
\[W_{2}=\{ABCD,ABCD\}. \tag{7}\]  
Log \(W_{2}\) contains a loop, as task \(B\) is executed two times. Figure 6 presents activity graphs created as a result of executing Algorithm 1 with the logs \(W_{1}\) and \(W_{2}\) as input data. If the rule from algorithm \(\alpha\) were applied, then doubled edges between activities \(B\) and \(C\) would need to be removed in both graphs. In the second graph, this would result in a connectivity loss, as the vertex representing activity \(C\) would not be reachable from the initial node. [PERSON] et al. [68] proposed an extension to the \(\alpha\) algorithm, which includes the discovery of length-two loops. In this extension, a new ordering relation \(\Delta\) was defined. It is used to identify short loops as follows: given two tasks \(A\) and \(B\) being part of workflow log \(W\), \(A\Delta_{W}B\) if and only if a sequence \(ABA\) is a part of at least one trace in \(W\). Another introduced ordering relation is \(\diamond\), which is valid when \(A\Delta B\) and \(B\Delta A\). As a consequence, tasks \(A\) and \(B\) cannot be considered parallel if \(A\diamond B\). Such a solution could handle basic loop structures; however, it is unable to identify relations properly between tasks shown in Figure 6b without further modifications. In this case, \(B\Delta C\) is true, while the reciprocal relation \(C\Delta B\) does not imply. As a solution to this problem, we propose a redefinition of task parallelism, which can be applied to activity graphs defined by Formula 5. Given a workflow log \(W\) over a set of tasks \(T\) and activity graph \(G_{A}\) created based on \(W\), two tasks \(A,B\in T\) can be considered parallel if and only if:  
1. There exists a directed edge leading from \(A\) to \(B\) and one from \(B\) to \(A\). 2. There exists a workflow trace \(\sigma\in W\) where the number of occurrences for \(A\) and \(B\) is equal. 3. There exist two workflow traces \(\sigma_{1},\sigma_{2}\in W\) such that \(A\) occurs first before the first occurrence of \(B\) in \(\sigma_{1}\) and \(B\) occurs first before the first occurrence of \(A\) in \(\sigma_{2}\). Parallelism relations can be also identified using Prime Event Structures (PES) [69]. This method is based on the assumption that two events are considered to be concurrent if there are neither causality  
Figure 6: Activity graphs created from the example workflow logs: (**a**) \(W_{1}\) and (**b**) \(W_{2}\). nor conflict relations between them [70]. Having properly identified potentially parallel pairs of tasks, it is possible to run the refinement procedure of set \(E\). Its objective is to remove all edges from activity graph \(G_{A}\), the endpoints of which satisfy the three aforementioned conditions of activity parallelism. In the next step, an activity graph needs to be transformed into a business process graph, which is a precise representation of a BPMN process model. As a complex gateway structure may appear, this task includes mainly the identification and connection of logical gateways present in the process, which has been discussed in our previous work [71]. Similarly to the model used to generate synthetic workflow traces based on the process specification, the algorithm for discovering complex gateway structures was modeled as a constraint satisfaction problem in the MiniZinc environment. Given a predefined set of constraints, which ensure a proper flow between gateways, the process composition algorithm includes the dynamic creation of an input data file and running the simulation for each graph vertex, the indegree or outdegree of which is greater than two. Algorithm 2 describes the identification of places where complex gateway structures are needed, as well as the iterative execution of MiniZinc simulations for structure discovery. The example method applies to split gateways.