@@ -97,6 +97,8 @@ def visit_Return(self, node):
97
97
def calculate_node_levels (flow : Any ) -> Dict [str , int ]:
98
98
"""
99
99
Calculate the hierarchical level of each node in the flow.
100
+
101
+
100
102
Performs a breadth-first traversal of the flow graph to assign levels
101
103
to nodes, starting with start methods at level 0.
102
104
@@ -109,13 +111,13 @@ def calculate_node_levels(flow: Any) -> Dict[str, int]:
109
111
-------
110
112
Dict[str, int]
111
113
Dictionary mapping method names to their hierarchical levels.
112
- Notes
114
+
115
+ Notes
113
116
-----
114
117
- Start methods are assigned level 0
115
118
- Each subsequent connected node is assigned level = parent_level + 1
116
119
- Handles both OR and AND conditions for listeners
117
120
- Processes router paths separately
118
-
119
121
"""
120
122
levels : Dict [str , int ] = {}
121
123
queue : Deque [str ] = deque ()
@@ -219,7 +221,10 @@ def build_ancestor_dict(flow: Any) -> Dict[str, Set[str]]:
219
221
220
222
221
223
def dfs_ancestors (
222
- node : str , ancestors : Dict [str , Set [str ]], visited : Set [str ], flow : Any
224
+ node : str ,
225
+ ancestors : Dict [str , Set [str ]],
226
+ visited : Set [str ],
227
+ flow : Any
223
228
) -> None :
224
229
"""
225
230
Perform depth-first search to build ancestor relationships.
@@ -263,9 +268,7 @@ def dfs_ancestors(
263
268
dfs_ancestors (listener_name , ancestors , visited , flow )
264
269
265
270
266
- def is_ancestor (
267
- node : str , ancestor_candidate : str , ancestors : Dict [str , Set [str ]]
268
- ) -> bool :
271
+ def is_ancestor (node : str , ancestor_candidate : str , ancestors : Dict [str , Set [str ]]) -> bool :
269
272
"""
270
273
Check if one node is an ancestor of another.
271
274
@@ -330,9 +333,7 @@ def build_parent_children_dict(flow: Any) -> Dict[str, List[str]]:
330
333
return parent_children
331
334
332
335
333
- def get_child_index (
334
- parent : str , child : str , parent_children : Dict [str , List [str ]]
335
- ) -> int :
336
+ def get_child_index (parent : str , child : str , parent_children : Dict [str , List [str ]]) -> int :
336
337
"""
337
338
Get the index of a child node in its parent's sorted children list.
338
339
0 commit comments