I hope this question makes sense.
I have a subset of our customer base, as well info about how they're linked.
What I'm trying to do is identify how many unique customer "clusters" there are.
I created a table that contains the customer info, along with the other customers to which they're linked. Here's a simplified version:
So in the example above, Customer A is linked to B, which is linked to C, which is linked to D and E. Customer A is also linked to H.
Customer F is only linked to G.
In this case there are two "clusters" (A,B,C,D,E,H and F,G) and that's the number I'm trying to get to.
The table contains both combinations of the link, i.e. both A/B and B/A but it should be trivial to remove those.
I believe I need to use recursion, but I've been working on it for a while now, and I just can't get it to work properly.
Any help would be greatly appreciated.