<div class="gmail_quote">On Tue, Sep 21, 2010 at 12:19 AM, Alf P. Steinbach /Usenet <span dir="ltr"><<a href="mailto:alf.p.steinbach%2Busenet@gmail.com">alf.p.steinbach+usenet@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Uhm, thinking about it (it must have been my unconscious mind doing the work, it just popped into my head), if you first sort each individual equivalence relation so that you never have e.g. C=A but only A=C and so on, and then sort the list of equivalences, then it should reduce to walking the list and just starting a new set whenever a symbol is encountered that isn't yet in a set.<br>

</blockquote><div><br>This won't work for all inputs.  Consider the input: [('a', 'd'), ('b', 'c'), ('c', 'd')]<br><br>Expected Output:<br><br>1, a<br>1, b<br>1, c<br>1, d<br>

<br>Actual Output:<br><br>1, a<br>1, d<br>2, c<br>2, b<br>2, d</div><br>Cheers,<br>Ian<br><br></div><div style="visibility: hidden; display: inline;" id="avg_ls_inline_popup"></div><style type="text/css">#avg_ls_inline_popup {  position:absolute;  z-index:9999;  padding: 0px 0px;  margin-left: 0px;  margin-top: 0px;  width: 240px;  overflow: hidden;  word-wrap: break-word;  color: black;  font-size: 10px;  text-align: left;  line-height: 13px;}</style>