Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Edges in BPMN and graph #203

Closed
YJDave opened this issue Jan 29, 2021 · 2 comments
Closed

Multiple Edges in BPMN and graph #203

YJDave opened this issue Jan 29, 2021 · 2 comments

Comments

@YJDave
Copy link
Contributor

YJDave commented Jan 29, 2021

The BPMN model allows to add multiple edges(edges with same source and target nodes). However, the graph from BPMN do not as it is DiGraph.

It has to be MultiDiGraph. However it does not need to pass the name attribute while adding edge in graph to allow multiple edges.

BPMN allows multiple edges by providing different names. However, the graph from bpmn do not show multiple edges. Even if the name attribute is passed to graph(fix in #202) it won't show multiple edges, because bpmn creates nx.DiGraph()

In [26]: y = BPMN.Flow(a, b, name='y')

In [27]: bpmn = BPMN()

In [28]: bpmn.add_flow(x)

In [29]: bpmn.add_flow(y)

In [30]: bpmn.get_flows()
Out[30]:
{id7daf881a-fcb5-4ec3-9dc5-b86978402c47@a -> id4e566611-6a18-4f49-be78-576674b092d0@b,
 id7daf881a-fcb5-4ec3-9dc5-b86978402c47@a -> id4e566611-6a18-4f49-be78-576674b092d0@b}

In [31]: bpmn.get_graph().edges()
Out[31]: OutEdgeView([(7daf881a-fcb5-4ec3-9dc5-b86978402c47@a, 4e566611-6a18-4f49-be78-576674b092d0@b)])

In nx.DiGraph() it is not possible to have multiple edges. The nx.MultiDiGraph() fixes the issue. However the bpmn add/remove flows/tasks needs to tested for MultiDiGraph() to make sure it works as expected, because MultiDiGraph() adds new edge even if all values(source, target, attribute) are same(shown below).

In [32]: g = nx.DiGraph()

In [34]: g.add_edge("a", "b", name='x')

In [35]: g.add_edge("a", "b", name="y")

In [36]: g.edges()
Out[36]: OutEdgeView([('a', 'b')])

In [37]: g.edges(data=True)
Out[37]: OutEdgeDataView([('a', 'b', {'name': 'y'})])

In [38]: g = nx.MultiDiGraph()

In [40]: g.add_edge("a", "b", name='x')
Out[40]: 0

In [41]: g.add_edge("a", "b", name="y")
Out[41]: 1

In [42]: g.edges()
Out[42]: OutMultiEdgeDataView([('a', 'b'), ('a', 'b')])

In [43]: g.edges(data=True)
Out[43]: OutMultiEdgeDataView([('a', 'b', {'name': 'x'}), ('a', 'b', {'name': 'y'})])

In [44]: g = nx.MultiDiGraph()

In [45]: g.add_edge("a", "b")
Out[45]: 0

In [46]: g.add_edge("a", "b")
Out[46]: 1

In [47]: g.edges()
Out[47]: OutMultiEdgeDataView([('a', 'b'), ('a', 'b')])

In [48]: g.edges(data=True)
Out[48]: OutMultiEdgeDataView([('a', 'b', {}), ('a', 'b', {})])

My question is, what is expected? Is multiple edges in BPMN allowed, if yes then why its corresponding graph is DiGraph?

@fit-alessandro-berti
Copy link
Contributor

Good afternoon.

The BPMN standard allows for multiple edges between the same activities. Hence, we will accept your suggestion to use MultiDiGraph for the underlying graph object, after some testing.

@fit-alessandro-berti
Copy link
Contributor

Dear YJDave,

The issue has been resolved in version 2.2.0 !

fit-alessandro-berti pushed a commit that referenced this issue Feb 2, 2024
…mputation-in-the-simplified-interface' into 'integration'

[Priority 2] Adding methods for generalization and simplicity computation in the simplified interface

Closes #203

See merge request process-mining/pm4py/pm4py-core!1201
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants