# Gaining Insights into Conceptual Models: A Graph-Theoretic Querying Approach
## 4 Mapping an OPM Model to a Graph
### Nested OPM Thing Flattening
#### 4.1.2 Processing Links in Nested OPM Things  
The OPM links connected to refined (in-zoomed or unfolded) OPM things can be direct, which means that they are incoming to or outgoing from the nested process. In Figure 5, the **unsecured** and **secured** states are linked directly to the subprocess **Seatbelt Pulling** and from the subprocess **Buckle Clicking**. Indirect relations are connected to the circumference of the enclosing, in-zoomed process. An OPM enabler is an object that enables the process occurrence but is not transformed by that process. In Figure 5, the objects **Passenger Seatbelt** (an instrument, i.e., a non-human enabler) and **Passenger** (an agent, i.e., a human enabler) are connected with OPM enabling links (an instrument link--the white lollipop--and an agent link--the black lollipop--respectively) to **Passenger Securing**. Additional attention needs to be paid to OPM things that appear in more than one OPD and at different detail levels. Figure 4: Example of stateful object de-stating. Left: original model with a stateful object. Right: de-stated object with two specializations and links correctly migrated. A pseudo-code for the entire Flattening algorithm is listed in Algorithm 2. ```
1. Clone all the OPM model elements to a new flattened OPD
2. Execute the Stateful Object De-Stating algorithm (Algorithm 1)
3. For each OPM Thing connected (incoming/outgoing link) to/from an in-zoomed or unfolded OPM Thing in the parent level OPD 3.1. If the OPM Thing is not connected to any nested OPM Thing in any child level OPD 3.1.1. Copy OPM Link from original OPM Thing to each nested OPM Thing 3.1.2. Remove original OPM Link from OPM Thing to the in zoomed OPM Thing 3.2. Else remove OPM Thing and OPM Link to the unfolded OPM Thing
4. For each nested OPM Thing in child level OPD 4.1. In case OPM Thing is an Object 4.1.1. Create a new OPM Unidirectional Tagged Link between the nested objects ordered by the graphical position within the unfolded object 4.2. In case OPM Thing is Process 4.2.1. Create a new OPM Invocation Link between the nested processes ordered by the graphical position within the unfolded process 4.2.2. Create a new OPM Aggregation-Participation Link from the unfolded process to the nested processes end
```  
**Algorithm 2**OPM Model Flattening Algorithm  
The complexity of this algorithm is linear, \(O(n)\), by the number \(n\) of elements (things and links). The de-stating algorithm discussed above contributes at most \(m\) links, where \(m\) is the total number of states in the model. Likewise, \(k\), the number of new links due to Step 4.1 of the algorithm, is the number of elements in refined OPDs. Thus \(m<n\), and \(k<n\), and the complexity of this algorithm is \(O(n+m+k)=O(n)\). To demonstrate this algorithm, suppose the OPD on the left-hand side of Figure 4 contains an additional instrument, **Passenger Seatbelt**, with an outgoing instrument link to the process **Passenger Seatbelt**. The agent **Passenger** has two states: **unsecure** and **secure**,  
Figure 5: The in-zoomed process **Passenger Seuring** with links to the nested processes and to the circumference. connected with an input-output link pair. Figure 5 is a descendant OPD that contains two nested subprocesses inside **Passenger Securing: Seatbelt Pulling**, with a split input-output link pair, depicted as an incoming consumption link from the state **unsecure** of the **Passenger**, and **Buckle Clicking**, with an outgoing result link to the state **secure**. The OPD in Figure 6 is the result of applying the Flattening algorithm on this model. Step 4.2 in the Flattening Algorithm adds two new agent links from the agent **Passenger** to the two subprocesses that were nested within the in-zoomed process and are now unfolded: **Seatbelt Pulling** and **Buckle Clicking**. The algorithm also adds two new instrument links from the instrument **Passenger Seatbelt** to these two subprocesses, replacing the original one from **Passenger Securing**.