I have a very large dataset with two columns of interest: Name and Cousin.
Each row has a unique name and each name has a cousin.
The data is mutually inclusive, so the cousin's name will also appear as another row in the data.
The effect is therefore a big dataset with lots of names of people who are related to each other.
The relations, however, form themselves into separate groups. These are groups that have no relation with any person in any other group.
E.g (using -> to denote a relation)
A->C->E->G = Group 1
B->D->F->H = Group 2
None of the people in Group 1 shares a relation with any person in Group 2.
So, I'm looking for an approach to find these groups of related people using only their names and relations. This could be some pseudo-code or a conceptual approach, anything to point me down the right path.
Example dataset:
Name Cousin
A C
B D
C E
D F
E G
F H
G E
H K
I M
K H
M I
This data would be aggregated into three groups: Group 1 (A,C,E,G); Group 2 (B,D,F,H,K); Group 3 (I,M).