Process Trees

PM4Py offers support for process trees, including visualization, conversion to Petri nets, log generation, importing/exporting, and tree generation functionality. This section outlines these features.

Importing/Exporting Process Trees

PM4Py supports importing and exporting process trees in the PTML format. Use the following code to import a process tree from a PTML file:

                
            
Visualization of the object referenced in the example.

Use the following code to export a process tree to a PTML file:

        
      

Generation of Process Trees

The 'PTAndLogGenerator' approach, described in the paper 'PTAndLogGenerator: A Generator for Artificial Event Data', has been implemented in the PM4Py library. The following code snippet can be used to generate a process tree. Review the parameters below:

                
            
Visualization of the object referenced in the example.

Below is a table explaining the parameters used in the process tree generation:

ParameterMeaning
MODEMost frequent number of visible activities (default 20)
MINMinimum number of visible activities (default 10)
MAXMaximum number of visible activities (default 30)
SEQUENCEProbability of adding a sequence operator to the tree (default 0.25)
CHOICEProbability of adding a choice operator to the tree (default 0.25)
PARALLELProbability of adding a parallel operator to the tree (default 0.25)
LOOPProbability of adding a loop operator to the tree (default 0.25)
ORProbability of adding an OR operator to the tree (default 0)
SILENTProbability of adding silent activities to choice or loop operators (default 0.25)
DUPLICATEProbability of duplicating an activity label (default 0)
LT_DEPENDENCYProbability of adding random dependencies to the tree (default 0)
INFREQUENTProbability of making a choice have infrequent paths (default 0.25)
NO_MODELSNumber of trees to generate from the model population (default 10)
UNFOLD Whether to unfold loops to include choices in dependencies (0 = False, 1 = True).
If LT_DEPENDENCY ≤ 0, this should always be 0 (False).
If LT_DEPENDENCY > 0, this can be either 0 or 1 (True or False).
(default 10)
MAX_REPEATMaximum number of loop repetitions (used only when unfolding is True) (default 10)

Generation of a Log from a Process Tree

Use the following code snippet to generate a log with 100 cases from a process tree:

        
      

Conversion to Petri Net

Use the following code to convert a process tree into a Petri net:

                
            
Visualization of the object referenced in the example.

Visualizing a Process Tree

A process tree can be printed as shown below:

        
      

A process tree can also be visualized as follows:

                
            
Visualization of the object referenced in the example.

Converting a Petri Net to a Process Tree

We present an approach to convert a block-structured accepting Petri net into a process tree. The method is based on the work by van Zelst, Sebastiaan J., "Translating Workflow Nets to Process Trees: An Algorithmic Approach" (arXiv preprint arXiv:2004.08213, 2020).

The approach returns a process tree for block-structured Petri nets and raises an exception if the Petri net is not block-structured. Below is an example of this approach:

First, we load an XES log and discover an accepting Petri net using the Alpha Miner algorithm:

                
            
Visualization of the object referenced in the example.

Next, we convert this Petri net into a process tree:

        
      

The method succeeds since the accepting Petri net is block-structured and generates a process tree (which, in this case, coincidentally matches the process tree discovered by the inductive miner).

Frequency Annotation of a Process Tree

By default, a process tree does not include frequency or performance annotations. To optimally match a log against a process tree, you can use the alignments algorithm. The results of this algorithm provide a list of visited leaves/operators during replay, which can then be used to infer the frequency of each node at the case/event level in the process tree.

The following code can be used to add frequency annotations to the nodes of a process tree:

        
      

A frequency-based visualization of the process tree is also available: