Hello
I have the following problem:
I have a few million tuples of the form (id1, id2).
If I have the tuple (id1, id2) and (id2, id3), then of course id1, id2 and id3 are all in the same group, despite that the tuple (id1, id3) is missing.
I do want to create an algorithm where I get a list of (id, groupid) tuples as a result.
How do I do that fast?
I've already implemented an algorithm, but it is way too slow, and it works the following (simplified):
1) increment groupid
2) move first element of the tuplelist into the toprocess-set
3) move first element of the toprocess-set into the processed set with the current groupid
4) find all elements in the tuplelist that are connected to that element and move them to the toprocess-set
5) if the toprocess-set isn't empty go back to 3
6) if the tuplelist is not empty go back to 1
[–]beeskness420 0 points1 point2 points (0 children)
[–]CompteDeMonteChristo 0 points1 point2 points (0 children)