Skip to content

sys: Add Disjoint-set (union-find) data structure #93300

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rruuaanng
Copy link
Contributor

Add a set of Disjoint-set functions (find, union) to handle queries between sets.

@rruuaanng rruuaanng changed the title sys: Add Disjoint-set data structure sys: Add Disjoint-set (union-find) data structure Jul 18, 2025
@rruuaanng rruuaanng marked this pull request as ready for review July 18, 2025 06:21
@zephyrbot zephyrbot added area: Utilities area: Base OS Base OS Library (lib/os) labels Jul 18, 2025
Copy link
Member

@henrikbrixandersen henrikbrixandersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New features should have test cases added.

@zephyrbot zephyrbot added the Release Notes To be mentioned in the release notes label Jul 19, 2025
@rruuaanng rruuaanng force-pushed the add-uf branch 2 times, most recently from f37ab3c to 8583e82 Compare July 19, 2025 04:00
@zephyrbot zephyrbot requested review from cfriedt and jhedberg July 23, 2025 02:06
Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design note on the pointer handling.

Also count me on team sys_set_. "uf" is an expression of deep exasperation.

*/
struct uf_node {
/** @cond INTERNAL_HIDDEN */
struct uf_node *parent;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks suspiciously like an slist, no? Not like linked list handling is that big a deal, but every byte of code savings helps.

@rruuaanng rruuaanng force-pushed the add-uf branch 2 times, most recently from de9abc2 to f7d79b5 Compare July 25, 2025 08:38
Add a set of Disjoint-set functions (`find`, `union`)
to handle queries between sets.

Signed-off-by: James Roy <[email protected]>
Add unit tests for functions (`sys_set_makeset`,
`sys_set_union` and `sys_set_find`).

Signed-off-by: James Roy <[email protected]>
Comment on lines +70 to +75
* Utilities

* :c:struct:`set_node`
* :c:func:`sys_set_makeset`
* :c:func:`sys_set_find`
* :c:func:`sys_set_union`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put it in between the zephyr-keep-sorted comments.

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Base OS Base OS Library (lib/os) area: Utilities Release Notes To be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants