in reply to treat pairs, set as one item: looking for better way
It's a classical problem from graph theory.
Your pairs are edges and you wanna determine connectivity resp. connected components.
Don't know if the other posters are aware of edge cases (your example data is too simple to show them).
But there are already efficient (and proven) algorithms available!
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: treat pairs, set as one item: looking for better way
by remiah (Hermit) on Oct 19, 2013 at 11:58 UTC |