Skip to content
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

Trying to understand the union find #9

Closed
kounkou opened this issue Dec 30, 2019 · 1 comment
Closed

Trying to understand the union find #9

kounkou opened this issue Dec 30, 2019 · 1 comment

Comments

@kounkou
Copy link

kounkou commented Dec 30, 2019

Hey @coells,

Could you provide some details about the union find code please?
For instance if I give the following intervals as input :

[[1,2], [2,3], [4,5]]

why do I get as output :

('item', 0, '-> component', 0)
('item', 1, '-> component', 3)
('item', 2, '-> component', 3)
('item', 3, '-> component', 3)
('item', 4, '-> component', 5)
('item', 5, '-> component', 5)
('item', 6, '-> component', 6)
('item', 7, '-> component', 7)
('item', 8, '-> component', 8)
('item', 9, '-> component', 9)

Should I just ignore items 0, 6 -> 9 ? and notice that items 1, 2, 3 are as expected in the same group, and 4, 5 in another group?

regards

@coells
Copy link
Owner

coells commented Dec 30, 2019

Union-find is data structure that handles unification of equivalence classes, not intervals.

In your case [[1,2], [2,3], [4,5]] translates to 1=2, 2=3, 4=5 which means that you have two classes of equivalence {1, 2, 3}, {4, 5} and hence the algorithm outputs their components accordingly.

@coells coells closed this as completed Dec 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants