in reply to Re^2: Equivalence classes from equivalence relation and fingerprints
in thread Equivalence classes from equivalence relation and fingerprints

The other problem is when two objects of matching property are not adjacent even after the sorting because they are separated by an object with different property but accidentally matching fingerprint.

I think it does that too, actually. It's not as efficient as tye's solution, but it should work. I probably didn't describe it well enough, though, so let me have another crack at it.

  1. The (unwritten) output_sets function accepts a range that specifies a group of objects that have matching fingerprints.
  2. Turn that range into a list (say @fpmatches).
  3. shift the first item off @fpmatches and compare it to every other item in @fpmatches (with prop_matching). This should find every object with matching properties, regardless of how they sorted.
  4. The ones that match, output as a set, and remove from the @fpmatches list.
  5. Go back and shift off another object to compare, until the list is empty.