Lets say i have generated some random alphabets and random numbers
A 1
Z 2
C 3
L 2
E 4
and similarly another set
1 K
4 I
2 P
5 R
6 S
7 U
Now we can find 2 is linked to Z and L in the first case and similarly 2 is linked to P in the second set
from this we can say Z and L are connected to P
so intially i have generated the first two steps. I am a little confused how to proceed with rest?
The Graph module can help. In fact, concepts from Graph Theory are the right way to think about these sorts of problems instead of thrashing around with hashes and arrays trying to re-solve already solved problems.
Output
All weakly connected components
Connectedness tests