Dynamic-Graph Orientation
1 Orienting Acyclic Graphs
Throughout this post, 
 is an undirected acyclic graph on 
 vertices and 
 edges. The problem we want to solve is called graph orientation:
The input 
 is given in the insertion-only streaming model. That is, we know 
 in advance, and the set 
 is being revealed one edge at a time. For each edge 
 that we get, we need to assign a direction (i.e. an orientation), meaning to decide that it either points to 
 or to 
. When 
 points to 
 we denote it by 
. Note that when we assign a direction to a new edge, we may as well update the orientation of previously seen edges. When the stream ends, we left with a directed version of 
, denote it 
. 
We are interested in two metrics: the first is the outgoing degree bound, which is defined by the term 
 where 
 is the number of 
’s neighbors which 
 points to, in the oriented graph 
.
The second metric is a bound on the orientation cost for a single step of the stream. That is, a bound on the number of edge updates for every time a new edge is being revealed. 
Due to the fact that 
 is acyclic, we know it is actually a collection of one or more trees, then there exists an orientation 
 in which 
 (think that each node points to its parent in its corresponding tree).
2 Orientation Cost
Lets start with a very simple orientation rule: For every step of the stream, let 
 be the edge given in the current step, and 
. Consider the endpoints of 
. If 
 belongs to a larger connected component relative to the connected component of 
, under the graph induced by 
, then orient 
 to be 
, otherwise orient it 
. Note that 
 and 
 cannot be in the same connected component in 
.
Obviously, that update rule has constant orientation cost (in particular it never change the orientations of previous edges). However, the outgoing degree bound is 
. To prove that, consider some arbitrary vertex 
. We increase its outgoing degree by 
 when we make it points to another larger connected component. So every time the outgoing degree of 
 increases by 
, the size of its connected component is at least doubled. Since we have 
 vertices, we cannot double that size more than 
 times.
3 Outgoing Degree Bound
Now we will see an update rule that yields a constant degree bound, say 
: 
Upon receiving 
, orient it 
. Then, if the outgoing degree of 
 exceeds 
, we apply 
. This procedure will flip the orientation of any outgoing edge of 
. Next, check any neighbor 
 that was affected by this change, and apply 
 if it has more than 
 outgoing edges. This process continues recursively until no orientation is changed.
Interesting question that immediately pops to mind is, why this process of recursive updates eventually terminates? 
To see that infinite oscillation is impossible, consider some optimal orientation of 
, denote it 
, in which 
. Suppose that 
 was revealed to the stream, and let 
 be the chain of vertices that we applied 
 to, after orienting it. Denote by 
 the number of edges in 
 that don’t agree with 
, after applying 
 on 
. So for example, 
 is the number of conflicting edges right after we inserted 
 but before we start the recursive fixing process, and 
 is the number of conflicting edges after we flip all the outgoing edges of 
, and so on.
We will show that 
 is a strictly decreasing series, and since 
 cannot be negative, that series must terminates. Fix some 
, which is the number of edges conflicting with 
 before applying 
. In that moment, 
, but in the optimal orientation it should be at most 
, which means that at least 
 of 
’s outgoing edges have wrong orientations. So applying 
 adding up to one conflicting edge, but on the other hand, fixing the orientation of at least 
 other edges, thus the total number of conflicting edges with 
 decreased by at least 
, i.e. 
. 
It is immediate that this algorithm yields an orientation with outgoing degree bound of 
. We now move to show that the amortize orientation cost is also constant. To show that we will use the accounting method, in which we assign positive and negative values to different operations that we perform during processing the stream. As long as those values are constants, if in every step of the stream the aggregated value is non-negative, then we may conclude that the amortize cost per operation is also constant. So suppose that the action of inserting a new edge has a value of 
, and flipping orientation of an existing edge has a value of 
. We first prove the following claim.
Suppose we got a new edge 
, and let 
 be the series of vertices that we applied on 
 during the recursive fixing process, after inserting 
 to the graph. Then, all 
 are distinct, and the value of 
 is exactly 
 for any 
.
For the first part, if there is a vertex in 
 appearing twice, it means that we found a cycle in 
 which is impossible. For the second part, assume toward contradiction that we have 
 such that the outgoing degree of 
 was at least 6. It must be due to 
 application on some vertices from 
, which means that 
 has two neighbors in 
, and we know that those neighbors are connected, so we found a cycle in 
 and that is a contradiction.
It is left to show that at any point in time, the total value of previous operation is non negative. The following claim prove that.
For every step, 
, of the stream, let 
 be the edge revealed on that step. Let 
 be the series of vertices that we applied on 
 during the recursive fixing process, with 
 as defined before. Denote by 
 the aggregated value of all the operations done until inserting 
 (including) and after applying 
 to 
. Then, 
 for any 
.
By induction on 
. For 
, note that 
 and 
. For 
, we have 
 and 
, so using the induction hypothesis, 
 for 
, assume by induction on 
 that the claim holds, then 
4 Releasing the Assumptions
This post dealt with a relative simple model, in which the stream only revealing new edges but never deleting a previously seen one. In addition, we assume that our graph is acyclic which is also a very strong assumption. There are works that shows more sophisticated streaming algorithm for fully dynamic graphs (i.e. with edges insertions and deletions), and also works on general graphs that are not necessarily acyclic. Further details can be found in this paper.