<p>On our regular 666 research seminar we came up with the following proof.</p>

<p>We start with some definitions. Let P be our poset. For simplicity, suppose that none of the weights sum up to zero.
Denote the weight of a vertex by w(x) and the sum of the weights of a set by w(X).
We say that a set X is Y-up (closed) if it is contained in Y and every element of Y that is bigger than an element of X is also in X.
Similarly, say that a set X is Y-down if it is contained in Y and every element of Y that is smaller than an element of X is also in X.
In this language the set of marked elements must be always P-down.</p>

<p>We prove by contradiction. Take the shortest mark/unmark sequence that marks every element. We call such sequences full. At any given point, consider the set of elements that were marked before but are now unmarked. Denote this set by U.</p>

<p>Claim: w(U)>0.</p>

<p>Proof: We prove that the weight of any U-up set, X, is positive. The proof is by induction on the size of X.
If there is an X-down set, Y, such that w(Y)>0, then since by induction we know that w(X\Y)>0 (since it is X-up), we also have w(X)>0.
If for every X-down set, Y, we have w(Y)&lt;0, then by deleting up to this point all the markings and unmarkings of the elements of X from our sequence, we get a shorter full sequence. We are done with the proof of the claim.</p>

<p>Now suppose that we have a full sequence where w(U)>0 at any point for the set U of currently unmarked elements. Take the sequence that we obtain from this by taking the first marking of every element and never unmarking anything. It is clear that this will also be a full sequence satisfying that the set of marked elements is always P-down. Moreover, the sum of the weights will be always at least as much as in the original sequence since at any given time the difference is w(U). We are done.</p>

<p>With this method one can even prove that if instead of marking the whole of P, we only want to mark a subset of P, then it can be done with a sequence of markings followed by a sequence of unmarkings. The proof is the same except that at the end some elements, U, stay unmarked but these can be moved to the end of the sequence as the weight of any U-up set is positive.</p>

CC BY-SA 2.5
2010-11-10T22:31:15.173Z
Your definitions of Y-up and Y-down are identical.  Presumably a subset X of Y is Y-down if every element of Y that is *smaller* than an element of X is also in X.
Jeffε
CC BY-SA 3.0
2013-09-19T20:34:39.867Z
Very cool!  The answer might be clearer if the first line stated what statement you are proving.  I gather it's a proof that unmarking is never needed (if you can solve it using unmarking, you can find a sequence that also solves it without ever unmarking anything)? (And not, e.g., a proof that this problem is NP-hard/PSPACE-hard, or of a polynomial-time algorithm that can decide whether such a marking sequence exists (or find it).) Also, later in the exposition where it says "at any point", I'm not clear whether this means "at all points" or "at some point"; I suspect you mean the former?
D.W.
CC BY-SA 2.5
2010-11-10T18:24:25.027Z
2010-11-11T06:10:07.393Z
2010-11-11T06:10:07.393Z
domotorp
<p>This is a followup to <a href="https://cstheory.stackexchange.com/questions/1346/positive-topological-ordering">David Eppstein's recent question</a> and is motivated by the same  problems.</p>

<p>Suppose I have a dag with real-number weights on its vertices.  Initially, all of the vertices are unmarked.  I can change the set of marked vertices by either (1) marking a vertex with no unmarked predecessors, or (2) unmarking a vertex with no marked successors.  (Thus, the set of marked vertices is always a prefix of the partial order.)  I want to find a sequence of marking/unmarking operations that ends with all vertices marked, such that the total weight of the marked vertices is always non-negative.</p>

<ul>
<li><p><strong>How hard is finding such a sequence of operations?</strong>  Unlike <a href="https://cstheory.stackexchange.com/questions/1346/positive-topological-ordering">David's problem</a>, it's not even clear that this problem is in NP; in principle (although I don't have any examples) every legal move sequence could have exponential length.  The best I can prove is that the problem is in PSPACE.</p></li>
<li><p><strong>Is the unmarking operation actually unnecessary?</strong>  If there is a valid move sequence, must there be a valid move sequence that never unmarks a vertex?  An affirmative answer would make this problem <em>identical</em> to <a href="https://cstheory.stackexchange.com/questions/1346/positive-topological-ordering">David's</a>.  On the other hand, if unmarking is sometimes necessary, there should be a small (constant size) example that proves it.</p></li>
</ul>

CC BY-SA 2.5
2010-09-17T04:56:39.223Z
This paper shows that a loosely related problem is PSPACE-hard: http://arxiv.org/abs/1009.3217
Jeffε
CC BY-SA 2.5
2010-10-26T01:50:46.600Z
Sounds a lot like a pebbling game: http://en.wikipedia.org/wiki/Pebble_game .
Warren Schudy
CC BY-SA 2.5
2010-10-26T01:57:48.587Z
A recent pebbling paper: 
http://www.cs.utoronto.ca/~philipp/pages/papers/BWPebbling.pdf . The black pebbling game is similar to yours but different in that intermediate nodes can be unmarked even if a successor is marked.
Warren Schudy
<ds.algorithms><directed-acyclic-graph><partial-order>
Positive topological ordering, take 2
Jeffε
# Positive topological ordering, take 2

(Asked by: username_0 on 2010-09-17)

This is a followup to [David Eppstein's recent question](https://cstheory.stackexchange.com/questions/1346/positive-topological-ordering) and is motivated by the same problems.

Suppose I have a dag with real-number weights on its vertices. Initially, all of the vertices are unmarked. I can change the set of marked vertices by either (1) marking a vertex with no unmarked predecessors, or (2) unmarking a vertex with no marked successors. (Thus, the set of marked vertices is always a prefix of the partial order.) I want to find a sequence of marking/unmarking operations that ends with all vertices marked, such that the total weight of the marked vertices is always non-negative.

* **How hard is finding such a sequence of operations?** Unlike [David's problem](https://cstheory.stackexchange.com/questions/1346/positive-topological-ordering), it's not even clear that this problem is in NP; in principle (although I don't have any examples) every legal move sequence could have exponential length. The best I can prove is that the problem is in PSPACE.
* **Is the unmarking operation actually unnecessary?** If there is a valid move sequence, must there be a valid move sequence that never unmarks a vertex? An affirmative answer would make this problem *identical* to [David's](https://cstheory.stackexchange.com/questions/1346/positive-topological-ordering). On the other hand, if unmarking is sometimes necessary, there should be a small (constant size) example that proves it.

**Tags:** ds.algorithms, directed-acyclic-graph, partial-order

> **Comments:**
> **username_0**: This paper shows that a loosely related problem is PSPACE-hard: http://arxiv.org/abs/1009.3217  
> **username_1**: Sounds a lot like a pebbling game: http://en.wikipedia.org/wiki/Pebble_game .  
> **username_1**: A recent pebbling paper:  http://www.cs.utoronto.ca/~philipp/pages/papers/BWPebbling.pdf . The black pebbling game is similar to yours but different in that intermediate nodes can be unmarked even if a successor is marked.  

---

## 1 answers

### Answer by username_2 on 2010-11-10. Score: 5 | Accepted answer

On our regular 666 research seminar we came up with the following proof.

We start with some definitions. Let P be our poset. For simplicity, suppose that none of the weights sum up to zero.
Denote the weight of a vertex by w(x) and the sum of the weights of a set by w(X).
We say that a set X is Y-up (closed) if it is contained in Y and every element of Y that is bigger than an element of X is also in X.
Similarly, say that a set X is Y-down if it is contained in Y and every element of Y that is smaller than an element of X is also in X.
In this language the set of marked elements must be always P-down.

We prove by contradiction. Take the shortest mark/unmark sequence that marks every element. We call such sequences full. At any given point, consider the set of elements that were marked before but are now unmarked. Denote this set by U.

Claim: w(U)>0.

Proof: We prove that the weight of any U-up set, X, is positive. The proof is by induction on the size of X.
If there is an X-down set, Y, such that w(Y)>0, then since by induction we know that w(X\Y)>0 (since it is X-up), we also have w(X)>0.
If for every X-down set, Y, we have w(Y)<0, then by deleting up to this point all the markings and unmarkings of the elements of X from our sequence, we get a shorter full sequence. We are done with the proof of the claim.

Now suppose that we have a full sequence where w(U)>0 at any point for the set U of currently unmarked elements. Take the sequence that we obtain from this by taking the first marking of every element and never unmarking anything. It is clear that this will also be a full sequence satisfying that the set of marked elements is always P-down. Moreover, the sum of the weights will be always at least as much as in the original sequence since at any given time the difference is w(U). We are done.

With this method one can even prove that if instead of marking the whole of P, we only want to mark a subset of P, then it can be done with a sequence of markings followed by a sequence of unmarkings. The proof is the same except that at the end some elements, U, stay unmarked but these can be moved to the end of the sequence as the weight of any U-up set is positive.

> **Comments:**
> **username_0**: Your definitions of Y-up and Y-down are identical.  Presumably a subset X of Y is Y-down if every element of Y that is *smaller* than an element of X is also in X.  
> **username_3**: Very cool!  The answer might be clearer if the first line stated what statement you are proving.  I gather it's a proof that unmarking is never needed (if you can solve it using unmarking, you can find a sequence that also solves it without ever unmarking anything)? (And not, e.g., a proof that this problem is NP-hard/PSPACE-hard, or of a polynomial-time algorithm that can decide whether such a marking sequence exists (or find it).) Also, later in the exposition where it says "at any point", I'm not clear whether this means "at all points" or "at some point"; I suspect you mean the former?  

---

