algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -


i have sorting problem i'm pretty sure doesn't have canonical "answer" - has number of different approaches, each pros/cons. i'm interested in hearing different approaches.

suppose bunch of people {p_i | i=1,...,m} ranking favorite ice cream flavors. in total there n different flavors, single person p_i ranks n_i << n flavors or familiar with. i'm interested in combining these sub-rankings plausible overall ranking of n flavors.

for concrete situation: m , n both 1000 (by coincidence), , each n_i 20. can assume there's enough overlap in flavors people rank such no flavor "isolated".

again, i'm interested in hearing different ways approach this, if there isn't single clear answer. thanks!

one way approach problem construct directed cyclic graph representing of constraints on ordering of elements. nodes in graph represent different elements compared , have edge first node second node if had ranked first element has better second element. graph not large , can constructed in linear time creating 1 node every. object , adding edges based on preferences.

there 2 possibilities graph. first, if graph contains cycle, there must conflict in preferences , there's no way order elements consistently. second, if graph has no cycles, topological ordering of graph give overall consistent ordering of elements, since every element placed after elements transitively come before it.

hope helps!


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -