Alef1986 commited on
Commit
7b89dd3
·
verified ·
1 Parent(s): 9693551

Upload case_5.py

Browse files
Files changed (1) hide show
  1. cases/case_5.py +17 -2
cases/case_5.py CHANGED
@@ -14,8 +14,12 @@ def run(ctx):
14
  p_id = [k for k, v in processes.items() if v == p_name][0]
15
  nodes_to_draw, edges_to_draw = set([p_id]), []
16
 
17
- children = [v for u, v, d in G_full.out_edges(p_id, data=True) if 'Composition' in d.get('type','') and 'BusinessProcess' in G_full.nodes[v].get('type','')]
18
- nodes_to_draw.update(children)
 
 
 
 
19
 
20
  visited, current_front = set(nodes_to_draw), set(nodes_to_draw)
21
  for step in range(distance):
@@ -24,9 +28,14 @@ def run(ctx):
24
  for neighbor in U_active.neighbors(node):
25
  if neighbor not in visited:
26
  n_type = G_full.nodes[neighbor].get('type', '')
 
27
  if 'BusinessFunction' not in n_type and 'BusinessProcess' not in n_type:
28
  next_front.add(neighbor)
29
  visited.add(neighbor)
 
 
 
 
30
  nodes_to_draw.update(next_front)
31
  current_front = next_front
32
 
@@ -37,6 +46,12 @@ def run(ctx):
37
  edges_to_draw.append((u, v, G_active[u][v]))
38
  existing_edges.add((u, v))
39
 
 
 
 
 
 
 
40
  if ctx["connect_border_objects"]:
41
  edges_to_draw = enforce_border_object_relations(G_active, nodes_to_draw, edges_to_draw)
42
 
 
14
  p_id = [k for k, v in processes.items() if v == p_name][0]
15
  nodes_to_draw, edges_to_draw = set([p_id]), []
16
 
17
+ # Фикс 1: Принудительно собираем все ребра композиции из G_full, чтобы сабграфы всегда строились
18
+ comp_edges = []
19
+ for u, v, d in G_full.out_edges(p_id, data=True):
20
+ if 'Composition' in d.get('type','') and 'BusinessProcess' in G_full.nodes[v].get('type',''):
21
+ comp_edges.append((u, v, d))
22
+ nodes_to_draw.add(v)
23
 
24
  visited, current_front = set(nodes_to_draw), set(nodes_to_draw)
25
  for step in range(distance):
 
28
  for neighbor in U_active.neighbors(node):
29
  if neighbor not in visited:
30
  n_type = G_full.nodes[neighbor].get('type', '')
31
+ # Если это объект/артефакт - добавляем в отрисовку и идем через него дальше
32
  if 'BusinessFunction' not in n_type and 'BusinessProcess' not in n_type:
33
  next_front.add(neighbor)
34
  visited.add(neighbor)
35
+ # Фикс 2: Упираемся в ЛЮБОЙ смежный процесс (Function или Process)
36
+ else:
37
+ nodes_to_draw.add(neighbor)
38
+ visited.add(neighbor)
39
  nodes_to_draw.update(next_front)
40
  current_front = next_front
41
 
 
46
  edges_to_draw.append((u, v, G_active[u][v]))
47
  existing_edges.add((u, v))
48
 
49
+ # Фикс 1 (продолжение): Гарантируем присутствие ребер композиции в массиве для Mermaid
50
+ for u, v, d in comp_edges:
51
+ if (u, v) not in existing_edges:
52
+ edges_to_draw.append((u, v, d))
53
+ existing_edges.add((u, v))
54
+
55
  if ctx["connect_border_objects"]:
56
  edges_to_draw = enforce_border_object_relations(G_active, nodes_to_draw, edges_to_draw)
57