-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix cycle detection: parts_list_cycles #38127
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
Conversation
|
PR #38127: Size comparison from 794cc19 to c0c8c11 Full report (75 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
|
PR #38127: Size comparison from 794cc19 to e99ff0f Full report (75 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
| def parts_list_cycle_detect(visited: set, current_id: int) -> bool: | ||
| if current_id in visited: | ||
| return True | ||
| def parts_list_cycle_detect(visited: set, current_id: int, stack: set) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to find loops you generally only need a single stack, not two separate sets.
The issue here seems to be that we only add to visited, but never remove, so we actually detect more than cycles: we detect re-use across nodes. i.e. we detect non-cycles, but still invalid trees like in your example:
0 ───┐
↓ ↓
1 3
↳ 4 ↵
We should probably just re-name the error or add a comment explaing. The functionality seems on purpose and it does detect an invalid "tree".
The current
parts_list_cyclesfalsely reports a cycle with Oven device schema. Oven is being added in #38108Schema:
Using
chip-toolto queryparts-listfor each endpoint:Endpoint1:
Endpoint2:
Endpoint3
Endpoint4
Summary -
Output of current
TC_DeviceBasicComposition.py-When the above adjacency list represents a directed graph, there are no back edges and thus no cycle. But the current cycle detection function does not differentiate between back edges and cross edges.
Testing
src/python_testing/TC_DeviceBasicComposition.py