-
Notifications
You must be signed in to change notification settings - Fork 21
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
Unify boxes in result by default? #48
Comments
There should be a |
Hi! I decided to take a chance into this and found there is something weird with the implementation described above for 2 dimensions and above. The weird case is easily described with the next example
with the above algorithm the boxes are reduced to this
But I think thay should be reduced to just In #64 I add the unify keyword with a small but fast implementation of union-find (weighted and with path compression, reference on the algorithm here). The implementation is quite fast, two examples are the next ones (first from the tutorial)
the other mine
One thing is that if the implementation is changed so that the example showed at the begginig returns I'm open to thoughts and ideas. Hope is useful. P.D. Kudos to asciiflow for the ascii drawing. 😛 |
I don't understand why the algorithm doesn't reduce your example to |
Is because the |
Nice catch! Does your version give the correct result? |
A solution seems to be to modify the list of intervals as you go by taking the union (hull) when two intervals are combined, and checking the intersection with this modified list instead of the original list. |
Hmmm. But actually in your original example we would prefer not to unify (B1 ∪ B2) with B3, since they are actually disjoint. Maybe taking the hull is actually not a good idea. |
We can just return separate lists for each connected component and the user can take the hull if they prefer; or we can give a convenience function to do so. |
Maybe we can add three options for unify, |
I can add the algorithm for the hull too. I'll add it to the PR and make the changes on the documentation and add tests. |
@Suavesito-Olimpiada: Sorry for the delay in replying. I think it would be great to have these different options. Is there any progress on this? |
Note that there is also an implementation of disjoint sets in DataStructures.jl. I'm not sure how it compares to yours. |
I can check the differences between my inplementation and theirs, also see performan differences and reply back later. |
On the hull algorithm, I still don't have progress. But once I finish my semester I'll do it. :) |
I think there should be a way to use interval trees for this. There is an implementation in Julia. |
Or rather R-trees |
I'll check out both R-trees and Interval Trees, so I can understand better both structures. But as I see (just over-looking both articles) I think a variant of R-trees is closer to the hull idea (that is, so we can get the maximum number of non-intersecting hulls of intersecting intervals). |
I think the idea of R-trees is to make it more efficient to check which other boxes a given box intersects. |
From the R-Tree article
and from the Interval Tree article
|
And then
The bounding boxes are used to narrow down the set of existing boxes that a new box must be checked against, as far as I understand. |
See Samet, Foundations of Multidimensional and Metric Data Structures, chap. 3 |
Ok, ok I think both structures are used to optimise the search of intervals that overlaps other intervals, but I need to check the differences. Thanks for the information and all the references, I'll check them out. 😃 |
There's an implementation using LightGraphs in #5
It doesn't seem so easy to write an implementation by hand. It's basically a union-find algorithm
The text was updated successfully, but these errors were encountered: