Refactor: remove unused variable and optimize redundant computation

- Removed unused variable `all_routes_node_ids` to reduce code clutter.
- Moved `set(routes_node_ids.keys())` outside the loop to avoid repeated computation.
pull/22791/head
Yongtao Huang 7 months ago committed by GitHub
parent e9c43793b2
commit 151b94ef5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -639,11 +639,8 @@ class Graph(BaseModel):
if start_node_id not in reverse_edge_mapping:
return False
all_routes_node_ids = set()
parallel_start_node_ids: dict[str, list[str]] = {}
for branch_node_id, node_ids in routes_node_ids.items():
all_routes_node_ids.update(node_ids)
for branch_node_id in routes_node_ids.items():
if branch_node_id in reverse_edge_mapping:
for graph_edge in reverse_edge_mapping[branch_node_id]:
if graph_edge.source_node_id not in parallel_start_node_ids:
@ -651,8 +648,9 @@ class Graph(BaseModel):
parallel_start_node_ids[graph_edge.source_node_id].append(branch_node_id)
expected_branch_set = set(routes_node_ids.keys())
for _, branch_node_ids in parallel_start_node_ids.items():
if set(branch_node_ids) == set(routes_node_ids.keys()):
if set(branch_node_ids) == expected_branch_set:
return True
return False

Loading…
Cancel
Save