title: Algorithm for grouping related items
body: <p>I have a set of items. Each item in the set can be related to one or more other items. I would like to build an algorithm that group items that are related together, either directly or through other items.</p>
  
  <p><strong>Example :</strong>
  My set is {a, b, c, d, e, f}</p>
  
  <p>a and b are related. c is related to d and d is related to e.</p>
  
  <p>The algorithm should produce the following groups :
  {a, b}, {c, d, e}, {f}</p>
  
  <p>Any ideas of an efficient algorithm for doing this ? Thanks in advance :-)</p>