pm4py / pm4py-core

Public repository for the PM4Py (Process Mining for Python) project.
https://pm4py.fit.fraunhofer.de
GNU General Public License v3.0
722 stars 286 forks source link

DFG graph changes #414

Closed NKMatha closed 1 year ago

NKMatha commented 1 year ago

Hi,

Am looking to compare bpmn file with the dfg graph and highlight the dfg graph path(lets say green) which matches the bpmn graph. Is it possible to make this comparison? If yes, please let me know how could i achieve it.

fit-alessandro-berti commented 1 year ago

Dear @NKMatha

Please consider and adapt the following code:

import pm4py

log = pm4py.read_xes("tests/input_data/receipt.xes")

discovers the DFG from the log

dfg, sa, ea = pm4py.discover_dfg(log)

filters the log and discovers a process model from the log

filtered_log = pm4py.filter_variants_top_k(log, 6)

discovers a BPMN graph using the inductive miner algorithm on the filtered log

bpmn_graph = pm4py.discover_bpmn_inductive(filtered_log)

converts the BPMN to a Petri net

net, im, fm = pm4py.convert_to_petri_net(bpmn_graph)

try:

converts the Petri net to a process tree

process_tree = pm4py.convert_to_process_tree(net, im, fm)
# extracts the footprints from the process tree (very efficient!)
fps = pm4py.discover_footprints(process_tree)

except:

the model is not a block-structured process therefore it cannot be converted to a process tree

# extracts the footprints from the Petri net (less efficient)
fps = pm4py.discover_footprints(net, im, fm)

find the directly-follows relationships allowed by the model

allowed_rels = fps["sequence"].union(fps["parallel"])

prints every relationship of the DFG (sorted by number of occurrences) along with the fact that

is allowed or not by the model

dfg_list = sorted(list((x, y) for x, y in dfg.items()), key=lambda x: (x[1], x[0])) for el in dfg_list: if el[0] in allowed_rels: print(el, " is allowed") else: print(el, " IS NOT ALLOWED")

NKMatha commented 1 year ago

Thanks @fit-alessandro-berti,

So, as per the code can i set the color property to elements to dfg in last conditional loop?

fit-alessandro-berti commented 1 year ago

You would need to create a specific visualization for the use case

NKMatha commented 1 year ago

Hi @fit-alessandro-berti i would like to know that can we have dfg in a structured and organized way so that can be look good(like a flow charts something...), As of now my dfg nodes were getting scattered.

Javert899 commented 1 year ago

Unfortunately that's not possible. We already use the Dot algorithm which is very advanced. There are specialized algorithms but we'll not implement them in the near future in pm4py.