algorithmic problem
May. 5th, 2008 04:14 pmGiven a set L of permutations of a list, compute the maximal partial order (DAG) under which all lists in L are topological sorts. How would you do this? Can you do better than O(m n^2 k^2)? (m = number of lists in L, k = # of things in domain = the size of the elements of L)
Sounds like an ILP problem.
One idea: whenever a cycle is detected, all the elements are deemed incomparable.
Sounds like an ILP problem.
One idea: whenever a cycle is detected, all the elements are deemed incomparable.
(no subject)
Date: 2008-05-06 12:01 am (UTC)(no subject)
Date: 2008-05-06 12:07 am (UTC)What is an "item"?
(no subject)
Date: 2008-05-06 12:17 am (UTC)* take the UNION of all the complete DAGs corresponding to each list
* find all cycles there. A, B in the same cycle => A, B in the same "set" (permutations between things in the same set are graph automorphisms of the final DAG)
another idea
Date: 2008-05-06 12:21 am (UTC)(no subject)
Date: 2008-05-06 12:25 am (UTC)and there are k(k-1) edges to loop through.
(no subject)
Date: 2008-05-06 02:39 am (UTC)You don't need to loop through the entire set of edges just to mark one, hence you have an additive rather than multiplicative dependence on k2. O(mn2) to mark the edges, then another O(k2) to write out the edges that weren't marked.
Of course, what comes out isn't a DAG. We leave the final step as an exercise to the reader.
(no subject)
Date: 2008-05-06 03:44 am (UTC)Sure. But you want to mark *all* edges, right?
<< Marking edges is n work per item, >>
are you marking *all edges* in O(nk)?
(no subject)
Date: 2008-05-06 08:50 am (UTC)1. Use variables of some sort to denote things you're talk about
2. Don't call something a list unless its ordering is important
As far as I can tell you have:
A collection of k objects, let's call it X
A collection of linear orderings of subsets of X, which you call L
The size of L is m. Each linear ordering is on a subset of size n.
What you want to output is the maximum partial order of X which is a weaken of each element of L (on that element's domain).
If this is the right question, the answer is often not unique. For example, X={a,b,c} and L={[a,b],[a,c]}, then a maximal partial order will relate b and c in some way, but either way will do.
(no subject)
Date: 2008-05-06 02:24 pm (UTC)This will not happen if all lists in L are permutations of each other (as stated). I guess I should have noticed that k=n.
(no subject)
Date: 2008-05-06 02:32 pm (UTC)(no subject)
Date: 2008-05-06 03:53 pm (UTC)(no subject)
Date: 2008-05-06 03:59 pm (UTC)(no subject)
Date: 2008-05-06 06:08 pm (UTC)Therefore, all nodes in the same set have the same incoming and outgoing edges. This means we can collapse sets of nodes into "supernodes".
For the final DAG, you just make sure that there are no edges between members of the same set (and propagate each supernode's incoming and outgoing edges into all members... or you could just leave the final DAG in the supernode representation.
Re: another idea
Date: 2008-05-06 06:08 pm (UTC)(no subject)
Date: 2008-05-06 07:26 pm (UTC)(no subject)
Date: 2008-05-06 07:35 pm (UTC)(no subject)
Date: 2008-05-06 07:57 pm (UTC)