If the value has to match the key, the values are redundant. You may as well specify an array.
However, it's clear that the above rules aren't complete. After all, 'a|b', 'b|c', 'b|d', is illegal, yet all values contain two points.
It could very well be that all you require is an implementation of a Union-Find algorithm (which runs in time O(N ack-1N)), but without a good specification, we can't be sure. | [reply] |