title: A set union find algorithm
body: <p>I have thousands of lines of 1 to 100 numbers, every line define a group of numbers and a relationship among them.
  I need to get the sets of related numbers.</p>
  
  <p>Little Example:
  If I have this 7 lines of data</p>
  
  <pre><code>T1 T2
  T3 
  T4
  T5
  T6 T1
  T5 T4
  T3 T4 T7
  </code></pre>
  
  <p>I need a not so slow algorithm to know that the sets here are:</p>
  
  <pre><code>T1 T2 T6 (because T1 is related with T2 in the first line and T1 related with T6 in the line 5)
  T3 T4 T5 T7 (because T5 is with T4 in line 6 and T3 is with T4 and T7 in line 7)
  </code></pre>
  
  <p>but when you have very big sets is painfully slow to do a search of a T(x) in every big set, and do unions of sets... etc.</p>
  
  <p>Do you have a hint to do this in a not so brute force manner?</p>
  
  <p>I'm trying to do this in Python.</p>