4

I am looking for a data structure for storing a poset, that supports the following operations with good big-Oh complexity (these are done frequently):

  • determining if a given element can be consistently ordered before another one (top priority above others)
  • adding new ordering constraints
  • returning all elements that can be ordered before a given element

The data structure must also support generating a totally ordered set from the poset, but that only needs to be done once for the output after the algorithm has already run.

So far I have been relying on a naive poset implementation, but I am reaching a point where that is no longer sustainable.

I have looked at https://cstheory.stackexchange.com/questions/8503/what-persistent-data-structure-for-a-set-of-partially-ordered-elements, and there are some interesting papers in the answers, but most of these data structures (like ChainMerge) seem to be optimized with sorting in mind, where for me it is the least important step.

WhyNott
  • 43
  • 2
  • If you maintain the transitive closure -- i.e., a graph in which there is an edge x->y exactly when x > y -- then testing whether it's possible to add a new edge x->y is constant time (if you use an adjacency matrix (O(|V|^2) space) or adjacency list representation in which each vertex stores a hashtable of all vertices that it precedes): all you have to do is check for the absence of a reverse edge y->x. Updating this data structure when the edge is added is slow, however: worst case O(|V|). – j_random_hacker Oct 18 '19 at 23:13

0 Answers0