Efficient Data Structures for Partial Orders, Range Modes, and Graph Cuts