A Simple Greedy Algorithm for Dynamic Graph Orientation

Graph orientations with low out-degree are one of several ways to efficiently store sparse graphs. If the graphs allow for insertion and deletion of edges, one may have to flip the orientation of some edges to prevent blowing up the maximum out-degree. We use arboricity as our sparsity measure. With an immensely simple greedy algorithm, we get parametrized trade-off bounds between out-degree and worst case number of flips, which previously only existed for amortized number of flips. We match the previous best worst-case algorithm (in Ologn\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {O}\left( \log n\right) $$\end{document} flips) for almost all values of arboricity and beat it for either constant or super-logarithmic arboricity. We also match a previous best amortized result for at least logarithmic arboricity, and give the first results with worst-case O1\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {O}\left( 1\right) $$\end{document} and Ologn\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {O}\left( \sqrt{\log n}\right) $$\end{document} flips nearly matching out-degree bounds to their respective amortized solutions.

with low arboricity and supporting fast (O(α) time) adjacency queries in the worst case.
Brodal and Fagerberg [4] extended this idea to dynamic graphs, where edges may be arbitrarily inserted or deleted. If the arboricity of the graphs remains bounded by a constant α, the forest partitions may be forced to change due to the updates. The authors deal with this by considering the problem of orienting the edges of the dynamic graph as in [7], but by re-orienting ("flipping") edges as needed to maintain low outdegree. They gave a simple greedy algorithm and proved that its amortized number of flips was O(1)-competitive to the number of flips made by any other sequence of flips that maintains a bounded out-degree. In this paper, we will use the term (offline) strategy to describe such a sequence. In particular, Brodal and Fagerberg showed how to maintain the out-degrees bounded by O(α) with O(log n) amortized flips, where n is the number of vertices in the graph. They also gave a lower bound of Ω(n) flips for maintaining the out-degrees bounded by α. It is not hard to see that this bound holds even for α = 1.
Kowalik [9] gave another offline strategy and applied it to the algorithm by Brodal and Fagerberg, getting O(α log n) out-degree in constant amortized flips, demonstrating that a reasonable trade-off was possible. As stated, both the algorithms of Brodal and Fagerberg [4] and Kowalik [9] need to know, and use as a parameter, a bound on the arboricity of the graph. However it is straightforward to modify these algorithms to guess the arboricity, and automatically adjust the guess if the guess was wrong, without impacting their amortized time complexities.
Kopelowitz et al. [8] later found a different algorithm, which came with slightly worse bounds but in the worst case rather than amortized. Their algorithm maintains O(α + log n) out-degree with O(α + log n) flips, without knowing α. However, if α is known, they give an alternate algorithm with somewhat better running time for edge insertions, but otherwise equal bounds for out-degree and number of flips. Also, if α = O √ log n , both bounds can be improved slightly to O(log n/ log log n) due to some freedom in setting the base of the logarithmic terms.
He et al. [6] gave a new offline strategy with a parametrized trade-off between out-degree and flips, generalizing the two strategies in [4,9]. When applied to the algorithm by Brodal and Fagerberg it achieves O α √ log n out-degree with O √ log n amortized flips. They also give another algorithm with worst-case bounds, nearly matching the out-degree and flips of [8] but with somewhat simpler pseudocode and (if α = ω(log n)) improved time complexity for insertions.
The problem was originally motivated by quick adjacency queries [7]. But rather than making an explicit dictionary data structure, for most of the paper we focus on the problem of dynamically flipping edges to guarantee low maximum out-degree. This allows us to ignore lower bounds for dictionary operations, and we deliberately omit comparisons of update time complexity as they might be skewed unfairly in our favor. It is straightforward to create such a data structure on top of our machinery, should one so desire, by extending our solution to report which edges are flipped. This allows programmers to tailor the balance between update and query time to suit their own needs. In Sect. 7 we describe a higher-level data structure for adjacency queries with the best bounds yet (insertions, deletions and queries all in O(log log log n) worst-case Flip bounds marked 'am.' are amortized per update, others are worst-case deterministic time) for a certain setting, as well as some updated results on maintaining an approximate maximum matching.

Our Contribution
We present a new algorithm for maintaining an edge orientation of a dynamic graph, with a guarantee of low out-degree and worst-case number of flips. Like many previous solutions we relate the performance to the arboricity α of the dynamic graph, but unlike some previous works, ours does not require knowledge of the arboricity in the general case. Our algorithm is furthermore much simpler than previous ones, and uses queues as the only under-the-hood data structure. It owes its simplicity to the fact that it greedily chooses which edge to flip. By controlling a run-time parameter, our algorithm allows a user-specified trade-off between the out-degree and the number of flips; this was previously only possible for algorithms with amortized number of flips. Depending on the choice of the parameter, the algorithm can maintain e.g. O(α + log n) out-degree with O(log n) flips, or O α log 2 n out-degree with constant flips. Various other parameter settings are possible. We match or improve all known bounds with worst-case flips, except when the arboricity is within a specific, very narrow range (Table 1).

Preliminaries
The arboricity of a graph G is the smallest number t such that the edges of G can be partitioned into t forests. Several equivalent definitions are used throughout the literature. We use arboricity(G) to denote the arboricity of G. A graph G with bounded arboricity arboricity(G) ≤ α is sparse: any induced subgraph of G on n ≤ n vertices contains at most (n − 1)α edges. Note that while bounded arboricity graphs have no dense neighbourhood they can still have vertices of arbitrarily high degree, e.g. stars have arboricity 1 but maximum degree n − 1.
We a deletion). We typically assume G 0 = ∅. We say that G has bounded arboricity (by a number α), or that arboricity(G) ≤ α, if arboricity(G i ) ≤ α for every i.
An orientation of a graph G is a directed graph G with the same vertex and edge sets as G, but where an undirected edge (u, v) ∈ G exists as the directed edge (u, v) or (v, u) in G. We use deg(G) to denote the maximum out-degree of G; it is a corientation if deg(G) ≤ c. Any graph G with arboricity(G) ≤ α has an α-orientation; to see this, partition the edges into α forests, pick an arbitrary root in every tree, and direct every edge towards the root of its respective tree. We An online c-orientation algorithm A receives G as a stream and upon receiving update i, it produces G i as a function of G i and G i−1 . We also say that A maintains an online c-orientation of G.
To distinguish from an online algorithm, an (offline) c-orientation strategy κ is a sequence of c-orientations of G. A strategy κ is not necessarily computable, but when it is, we will abuse notation and also let the strategy κ refer to some algorithm producing κ.
We say that κ or A makes σ flips (in the worst case) if the number of flips between any two updates i, i + 1 is at most σ , and that it makes σ amortized flips if after any update i the total amount of flips is at most σ i.

The Algorithm
The algorithm takes an edit-sequence of graphs G as an online stream, and a positive integer parameter k. Each vertex v maintains a standard FIFO queue Q v which holds all of its out-edges; by deg(v) we mean |Q v |. On an insertion (deletion) update, orient the new edge arbitrarily (delete the edge via object reference) and then k times pick a vertex v with maximum out-degree and flip the first edge in Q v .
The book-keeping of out-degrees is easy to accomplish with O(1) overhead. Use e.g. an array A where each A[i] holds a doubly-linked list of every vertex with outdegree i, plus a pointer to the highest index in A containing a non-empty list. The pointer is easy to keep updated since insertions, deletions and flips can only change the out-degree of a vertex by 1.
We do not explicitly support queries. See pseudocode below for ease of reading.

Analysis
To show the efficiency of Algorithm 1, we will prove that its out-degree is competitive to an unknown offline strategy. For given G and k, let δ, σ and ε be values satisfying the following conditions: (i) there exists an offline δ-orientation strategy κ of G making at most σ flips in the worst case, (ii) 0 < ε ≤ 1, and (iii) k ≥ 1 + 1/ε + 2σ .
Remark 1 Algorithm 1 is completely oblivious to the values of δ, σ and ε, as well as any graph properties of G itself. Consequently it is possible to perform the analysis against several different strategies simultaneously, including strategies for only a contiguous sub-sequence of G.
The number of flips, and hence the running time, in Theorem 1 is trivial from the pseudocode. The rest of this section is dedicated to proving the bound on the outdegree. While the proof is quite non-trivial, the roadmap thereof is easy. We will associate potentials on all edges, so that the potential of an edge depends on where it is stored-hence potential is inserted or removed from the system as the edges are moved around. Then we show that either the total potential cannot increase, or the maximum out-degree is O(δ) in which case the potentials do not matter. Finally we re-interpret the moving of potentials as a game, where even an adversary cannot concentrate more than O((δε + 1) log n) extra potential in any single vertex-this also (roughly) bounds the maximum out-degree. For purposes of analysis, we consider each queue Q v to be two queues, the Front F v and Back B v . Edges are always inserted into B v , and extracted from F v . If F v is empty when an edge should be extracted from Q v , simply swap the two queues (by renaming) and then continue. Clearly, this is equivalent to using a single queue. We say an edge was flipped from v and to u if it was removed from Q v /F v and inserted into Q u /B u .
To bound the maximum out-degree, we introduce potentials on the edges. At update i, we say that an edge in G i is good if it has the same orientation as in κ(G i ) and bad otherwise. Good edges have 1 + 2ε potential if they are in a Front queue and 1 − ε in a Back queue. Bad edges have potential 1, except for the first 3δ bad edges in any Back queue which have potential 1 + ε. See Table 2 for an overview.
Let p(v) be the sum of potentials of all edges stored in Q v ,p(G) = max v p(v) and P(G) = v p(v). When we need to differentiate the potential of a vertex in a Table 2 Edge potential by type and placement in queue Front Back at the time that the algorithm was storing G i . Since Algorithm 1 does not know the values of δ or ε, it cannot determine the exact potential of a vertex. But as the following lemma shows, the out-degree of a vertex is a close approximation of its potential. We will prove the theorem by bounding the maximum potential of any vertex, which then implies a bound on its out-degree.

Lemma 1 For any vertex
Proof For the upper bound, all edges contribute a base 1 potential, accounting for the deg(v) term. Note that at most δ out-edges of v are good. If they are all placed in F v , they contribute an extra 2δε. At most 3δ bad edges in B v contribute an extra ε each, giving at most 5δε extra potential in total.
For the lower bound, only good edges in B v can contribute less than 1 potential. Again there are at most δ of these and they contribute ε less, giving at least deg(v) −δε potential in the vertex.
Let β = 6δε be the resolution of the system. The following states that the potential of the maximum out-degree vertex is not too far from the maximum potential of any vertex.
Lemma 2 Let u be some vertex with maximum potential, and let v be some maximum out-degree vertex.
The next two lemmas are used to show that the potential function is 'well-behaved' when performing flips from vertices with high enough out-degree.

Lemma 3 Assume a vertex v has an empty F v and at least 4δ edges in B v . Then swapping F v and B v does not increase p(v).
Proof The Back queue contains at most δ good edges and at least 3δ bad edges; hence exactly 3δ bad edges carry an extra ε potential which is released when moving from B v to F v . This 3δε potential is enough to raise the potential of all δ good edges from 1 − ε to 1 + 2ε.
In the case that there are fewer than δ good edges present in the queue at the moment of swapping F v and B v , any surplus potential released from bad edges is simply lost.

Lemma 4
Let v have out-degree at least 4δ. Then flipping an edge from v releases at least ε potential.
Proof By Lemma 3 we can assume F v is non-empty. Let (u, v) be the edge moved from F v to B u . Note that if the edge was previously good it is now bad, and vice versa. Hence its potential decreases either from 1 + 2ε to at most 1 + ε, or from 1 to 1 − ε.
We now shift our focus away from the potentials, and consider the out-degrees after an uninterrupted sequence of flips. Lemma 5 upper bounds the maximum out-degree after the flips. Specifically, if a prefix of the sequence lowers the maximum out-degree to some value, then the rest of the sequence (almost) cannot raise the out-degree again. Proof Note that flips can increase the maximum out-degree only if there are at least two vertices u, v with maximum out-degree, and the algorithm flips an edge incident on both of them. As soon as some vertex reaches out-degree d + 1, it will be the only vertex of maximum out-degree and immediately fall down to out-degree d in the following flip. Consequently no sequence of flips can raise a second vertex to outdegree d + 1, which is a necessary condition for raising any vertex to out-degree d + 2.
Hence, to bound the out-degree after all k flips, we only need to bound the outdegree before some individual flip anywhere in the sequence.
Conversely, Lemma 6 lower bounds the out-degrees of any vertex that loses edges via flipping, in relation to the rest of the graph. That is to say, vertex that used to have maximum out-degree will, after all flips, still have close to maximum out-degree. Later when we introduce the game, this lemma will be a crucial component.

Lemma 6
Let v be a vertex that had an edge flipped from it on update i. Then Proof Take the suffix S of flips that begins with the last flip from v. Before S, Consider the algorithm as it receives an update i. We say that the currently stored graph G i−1 has sufficient degree if each of the k flips associated with update i happens from a vertex with out-degree at least 4δ. Conversely, we say the graph G i−1 has insufficient degree if at least one of the k flips is from a vertex with out-degree less than 4δ.
Recall that bounding the out-degree of the graph is the overall goal. The following two lemmas show that either the total potential stored in the system is a non-increasing quantity, or the graph has nicely bounded out-degree anyway. In the latter case the potentials are of no interest.

Lemma 7 If G i−1 has insufficient degree, then deg(G i ) = O(δ).
Proof Since some edge was flipped from a vertex with out-degree d < 4δ, it follows from Lemma 5 that deg(G i ) ≤ d + 1 ≤ 4δ.

Lemma 8 If G i−1 has sufficient degree, then on update i the sum of potential released by flipping is at least as large as the sum of inserted potential.
Proof Since G i−1 has sufficient degree, each flip frees ε potential by Lemma 4 and together they release kε.
The offline strategy κ makes at most σ flips, which causes σ stored edges to swap their classification ("renaming") from good to bad or vice versa. A Front edge that was bad increases potential from 1 to 1 + 2ε, and a Back edge that was good increases from 1 − ε to at most 1 + ε. The renaming can therefore increase the total potential by at most 2σ ε. Assuming update i is an insertion, the new edge is inserted into a Back queue, and adds at most 1 + ε potential, and the sum of inserted potential is at most 1 + ε + 2σ ε. If the update was instead a deletion, at most 2σ ε potential is inserted.
The lemma therefore holds as long as kε ≥ 1 + ε + 2σ ε, which is guaranteed by the choice of these parameters.

Remark 2
If κ is known not to perform any flips on deletion updates, no potential gets added to the system (refer to the proof of Lemma 8). Hence our algorithm can also forgo flipping on deletions, without risking that the total potential increases.
Note that the potential of the system can increase on both insertion and deletion updates if the graph has insufficient degree, since we cannot rely on Lemma 3 to ensure that the potential of a vertex is well-behaved when flipping edges from it.
So far we have shown that either the maximum out-degree is O(δ), or we have a non-increasing quantity of potential and the out-degree of each vertex is closely approximated by its own potential. We next bound the maximum out-degree via a counter game, disassociated from the actual graph orientation, played by an adversary whose goal it is to concentrate as much potential as possible in a single counter. Counter games have been explored previously, under various names, in e.g. [5,10]: typically they may be thought of as two-player games where the second player is benevolent. Our game is different because the lone player is instead restricted by the concept of resolution β.
Formally, the game is played by a single player on n counters x 1 , . . . , x n . Each counter x i will hold a non-negative real-valued weight |x i |, and the sum of weights is a constant i |x i | = X . Any such distribution of X on the n counters is called a game configuration C. Letx = max i |x i | be the maximum weight at any time. The player can perform arbitrarily many iterations of the following three-step operation: (i) pick a counter x i and a c > 0 such that |x i | − c ≥ max(0,x − β − 2), (ii) remove c weight from x i and (iii) add positive weights whose sum is c to any set of counters.
The player is therefore allowed to redistribute weight to arbitrary counters, but must take it in not-too-large chunks, and only from counters that are within the resolution (here β + 2) of the maximum counter. Before upper-boundingx, we show that the player is powerful enough to simulate the movement of potentials by Algorithm 1. We say a game configuration C dominates a graph orientation G if |x j | ≥ p(v j ) for every j.

Lemma 9 Let i be an update such that G i−1 has sufficient degree. Let C be a game configuration that dominates G i−1 . Then the player can reach a game configuration C that dominates G i .
Proof We need to show that if some vertex gains potential (so its corresponding counter no longer dominates it), then we can safely take enough weight from other counters to fill that 'gap'. Keep in mind that the total potential does not increase (Lemma 8). Since the player is allowed to redistribute weight to any counter, we let the gaps be filled in arbitrary order and only show that enough weight can be taken from other counters to make up the difference. Ifx >p(G i−1 ) then greedily take weight from all counters greater thanp(G i−1 ) to getx =p(G i−1 ). This first step is required mostly out of technicality: we want to access the counters with at leastp(G i−1 ) − β − 2 weight, but can only access those with at leastx − β − 2 weight.
Let v j be a vertex that had an edge flipped from it. Then its resulting out-degree is . Also by Lemma 1 the maximum potential in the system isp(G i ) ≤ deg(G i ) + 5δε. Hence the final potential of v j is within 6δε + 2 = β + 2 of the maximum potential. As the rules of the counter game allow us to take weight up to β + 2 from the maximum counter, then however much potential v j lost we can take at least the same amount of weight from its corresponding counter x j .
Conversely, if a vertex loses potential but its resulting potential is not at least p(G i ) − β − 2, it must have lost that potential due to deletion or renaming rather than flipping. Its counter can safely be left untouched and still dominate the potential of the vertex.
Since the sum of potential decreases (by flipping) is at least as large as the sum of increases (for any reason) (Lemma 8), and for any vertex that lost potential by flipping we can remove at least as much weight from its counter, then we can redistribute enough weight to raise the too-low counters to again dominate their respective vertex potentials. The updated counters form a game configuration that dominates G i .

Lemma 10
Let G a , . . . , G b be any sequence of orientations such that G i has sufficient degree for every a ≤ i ≤ b. Consider a game with starting configuration C a that dominates G a , withx =p(G a ). Then the player can reach game configurations C a , . . . , We now let an adversary play the game, with the goal to increasex as much as possible. For simplicity we assume that every counter is raised tox to form the starting configuration. For j = −1, 0, 1, 2, . . . let j = X /n + j(β + 2) be weight level j. A counter x i is above level j, or above j , if |x i | ≥ j . Let X j = n i=1 max(0, |x i |− j ) be the weight above j , and X j = X − X j the weight below j . We say a counter x i contributes max(0, |x i | − j ) to X j and min(|x i |, j ) to X j . Lemma 11 Let j be a weight level such that j ≤x. Let the player make any sequence of moves that maintain the condition j ≤x. Then X j−1 does not increase.
Proof Note that any counter x i contributes min(|x i |, j−1 ) to X j−1 . By assumption there will always be a counter x k with j ≤ |x k |. Hence the resolution rule prevents the player from making any counter contribute less to X j−1 than it already does. Since X is a constant and X j−1 is non-decreasing, X j−1 = X − X j−1 is non-increasing.
Lemma 12 Let j be a weight level such that j ≤x ≤ j+1 . Let the player make any sequence of moves that maintain the condition j ≤x ≤ j+1 . Then 2X j ≤ X j−1 .
Proof By Lemma 11, X j−1 is a non-increasing amount. Let x i be any counter that will contribute some positive weight w to X j . Since the player maintains thatx ≤ j+1 , no counter will be able to contribute more than j+1 − j = β + 2 to X j , i.e. 0 < w ≤ β + 2. Then x i must contribute w + β + 2 to X j−1 . Hence any counter that contributes to X j contributes at least twice as much to X j−1 , and 2X j ≤ X j−1 .
The player is therefore stuck in the following dilemma: oncex reaches some level j , only a bounded amount X j−1 of weight remains available to redistribute, due to Lemma 11. But oncex reaches j+1 , the weight below j can no longer be redistributed due to the resolution rule. Therefore, in order to concentrate as much weight as possible above j+1 , the player must first maximize X j without any counter actually reaching above j+1 .

Lemma 13
The player cannot increasex to 1+log 2 n .
Proof Assumex ≥ log 2 n . Since 0 = X /n is the average weight of all counters, it must always be the case thatx ≥ 0 and X −1 ≤ n(β + 2). By alternatingly iterating Lemmas 11 and 12, the weight above log 2 n is X log 2 n ≤ 1 2 1+log 2 n X −1 = 1 2n X −1 ≤ 1 2n n(β + 2) < β + 2. Since the weight is strictly less than β + 2, even concentrating all of it in a single counter is not enough to make that counter reach 1+log 2 n . Hencê x < 1+log 2 n .
We are now ready to prove the out-degree part of Theorem 1.

De-amortizing Offline Strategies
In the previous work by Brodal and Fagerberg [4], their amortized algorithm is shown competitive with an offline strategy that has bounded amortized number of flips, and hence subsequently published strategies have focused on achieving good amortized bounds. However, for our algorithm analysis, we require an offline strategy with worstcase flips per update. In this section we show one way to de-amortize offline strategies. Our technique does not generalize to every offline strategy, but relies on the special structure inherent to the strategies of both [6,8]. These strategies partition the editsequence into blocks of consecutive updates, with some length λ. No flips occur within a block, only in the seams between two blocks. The amortized flip complexity of these strategies is therefore simply the maximum number of flips between two blocks, divided by the length λ of the preceding block. Since no flips are allowed within a block, the strategy is required to find an orientation of the union of all graphs G i , . . . , G i+λ−1 within a block. The maximum out-degree of the entire strategy is therefore upper bounded by the maximum out-degree of any oriented union-graph. Higher λ gives a less sparse union-graph, necessitating higher out-degree, but also allows for a better amortized flip complexity. The following theorem shows a simple way of de-amortizing strategies with this structure, by taking all the flips between two blocks and spreading them evenly over the updates in the later block.
Theorem 2 Let κ be a δ-orientation strategy of G where, for arbitrary λ, any update with σ λ flips is followed by at least λ − 1 updates with no flips. Then there exists a 2δ-orientation strategy of G making σ flips in the worst case.
Note that if the last block of flips is not followed by λ−1 updates due to G ending, then one can pad G to appropriate length by repeatedly inserting and removing a dummy edge after the end of G. Also note that λ can vary within the same sequence-blocks do not need to be of uniform length.
Proof Let i be an update where κ performs a set of λσ flips. Let F be the set of flipped edges. Let κ be an offline strategy with the same edge orientations as κ except for updates i, . . . , i + λ − 1. On any insertion update i, . . . , i + λ − 1, let κ orient the new edge in the same direction as κ. Furthermore, on each update i, . . . , i + λ − 1, κ takes σ arbitrary edges in F, removes them from F, and flips them.
Then F will be empty after update i + λ − 1, so κ(G i+λ−1 ) = κ (G i+λ−1 ). At all times F forms a δ-orientation, since F is a subset of κ(G i−1 ). Similarly, κ (G j ) \ F is δ-orientation for every i ≤ j ≤ i + λ − 1, since they are a subset of κ(G j ). Hence κ is a 2δ-orientation. Finally, κ performs at most σ flips per update between updates i and i + λ − 1; exhaustively perform the same transformation on all of κ for σ flips on any update.

Discussion
With our two theorems proven, we can relate the algorithm to known offline strategies and achieve the following corollaries. In all of the following, G is an arbitrary editsequence with arboricity(G) ≤ α.
Kowalik [9] presents an offline O(α log n)-orientation strategy making 1 amortized flip. Using Theorem 2 we can de-amortize it to an offline O(α log n)-orientation strategy making 1 flip in the worst case, giving the following two corollaries. He et al. [6] give an offline O α √ log n -orientation strategy making O √ log n amortized flips, which we de-amortize using Theorem 2.

Corollary 5 Algorithm 1 maintains an O(log n)-orientation of
Then the algorithm Corollary 4 is an improvement over [8] in the flip complexity for edit-sequences with arboricity bounded by a constant. For α = O √ log n/ log log n , Corollary 5 matches or improves the flip complexity from [8], albeit with a slightly worse out-degree bound, and only if α is known. If α is both O √ log n and ω( log(n)/ log log n) we are narrowly outperformed by [8], by no more than an O(log log n) factor. Corollary 4 also compares well against the amortized result from [6], with a O √ log n factor gap in the out-degree but with worst-case flips instead of amortized. Corollary 3 matches the bounds in [8] for general arboricity and improves on their flip complexity if α = ω(log n). Furthermore, if α = Ω(log n), Corollary 3 matches the amortized bounds from [4].

Reverse Trade-Off
Compared to an offline strategy, our analysis lends itself to a trade-off in one direction, getting (at most) an O(log n) factor on the out-degree for a constant factor on the number of flips. It allows us to perform much fewer flips than in [8] at the price of weaker out-degree bounds. A trade-off in the opposite direction would also be highly desirable, achieving out-degree (closer to) O(δ) by making Ω(σ ) flips. We have only found a very weak such trade-off: Proof Let δ = O(α) and ε = 1 (the value of σ is inconsequential). Then each edge holds between 0 and 3 potential. And since any G i has at most αn edges (by definition of arboricity), the total potential is between 0 and 3αn. Furthermore each flip releases 1 potential from the system, contingent on the graph having sufficient degree (Lemma 4). Hence after performing at most 3αn flips on any starting orientation G i , we must reach a state where the next flip does not release potential, contradicting Lemma 4, and so by Lemma 7 the graph has out-degree at most 4δ = O(α) after all flips.
Lemma 14 only matches the worst-case bound of the algorithm in [4], which has drastically better amortized performance. Hence it should not be used in practice. Still, we believe a stronger reverse trade-off is possible and conjecture the following:

Conjecture 1
There exists a positive increasing function f such that for any editsequence G with a δ-orientation strategy making σ flips in the worst case, and for any k ≥ 2 + σ , Algorithm 1 maintains an online O δ + σ +1 f (k) δ log n -orientation of G with k flips and in O(k) time.

Dynamic Arboricity
Throughout the paper we have done all our performance analysis against a static arboricity bound, i.e. a bound on the greatest arboricity seen anywhere in the edit-sequence. An interesting issue arises if the sequence contains contiguous subsequences, of non-trivial length, with higher or lower arboricity than elsewhere in the sequence. Some previous algorithms, e.g. one of the algorithms in [8] and the non-amortized algorithm in [6], adapt to increasing and decreasing arboricity automatically.
Our analysis immediately adapts to sequences with increasing arboricity, since the analysis can be performed on any prefix (or contiguous sub-sequence) of G (see Remark 1). In the case of periods with lower arboricity than earlier in the sequence, our algorithm obeys the new arboricity if the maximum out-degree is already within that new bound. In other words, if the maximum out-degree is already bounded relative to the new arboricity, then it will remain so. However, if the arboricity falls enough that the current maximum out-degree breaks the new bounds, our analysis does not require the maximum out-degree to decrease accordingly. Intuitively, using a k strictly larger than 1 + 1/ε + 2σ (thus experiencing a net loss of total potential with every update) should force the maximum out-degree to tend towards the updated out-degree bounds, similar to the proof of Lemma 14. However, we do not have a formal argument for this.

Open Problems
For all known strategies that maintain out-degree δ with σ (amortized) flips, it holds that δσ = Ω(α log n) and most achieve δσ = Θ(α log n). Can one design a strategy with δσ = o(α log n)? In [1] the first-named author shows that in the case of amortized flips, one needs only consider lazy strategies that flip a single directed path on insertion updates and do nothing on deletion updates.

Adjacency Queries
Consider an application where an existing algorithm uses an orientation algorithm with out-degree Δ and f flips, as a black-box tool. A natural dimension of consideration, from the point of the higher-level algorithm, could be Δ + f . None of our results improve on the previous solution with worst-case bounds in this dimension. But for an application whose time complexity depends only, say, logarithmically on Δ, we can leverage our lower flip complexity to yield improved bounds. One such application is adjacency queries in dynamic graphs where updates and queries are relatively equally frequent (and hence we choose to sacrifice query time in favor of improved update time).
Let G be an edit-sequence with arboricity(G) = O log t n for some constant t. Kowalik [9] applies the orientation algorithm with Δ = O(α log n) = O log t+1 n and f = O(1) amortized flips to perform insertions, deletions and queries in O(log log log n) time but where the bound for insertions is amortized. By replacing their orientation algorithm with Corollary 2 (where Δ = O α log 2 n and f = O(1) worst-case), we get the following. Theorem 3 Let G be a dynamic graph with arboricity(G) = O log t n at all times for some constant t. Then there exists a data structure which supports updates (insertion and deletion) and adjacency queries on G in O(log log log n) worst-case time.
This result improves on [9] by virtue of having only worst-case bounds. It also improves the worst-case solutions due to He et al. [6], with matching query time but where updates of both types can require Ω(log n) time.

Maintaining a Maximum Matching
Starting with [11], orientation algorithms have been a popular black-box tool for maintaining approximate maximum matchings in dynamic graphs. The current state of the art with this approach is a (3/2 + ε)-approximate maximum matching for arbitrary graph G [3], or (1 + ε)-approximate if G is bipartite [2], in O(α(α + log n)) time for any constant ε > 0. Both results use the orientation algorithm from [8] as a subroutine, which performs edge insertions in O(α(α + log n)) time and this dominates the total running time to update the matching. Corollary 3 achieves essentially the same bounds on out-degree and flips as [8], but in only O(log n) time. Hence by substituting their algorithm for ours we get the following. Theorem 4 Let G be a dynamic graph with arboricity(G) ≤ α and fix a constant ε > 0. Then one can deterministically maintain a (3/2 + ε)-approximate maximum matching of G with worst-case time O(α + log n) per update. If G is bipartite, the approximation ratio is (1 + ε).
Note that after this substitution the time to update the matching is no longer dominated by the running time of the re-orientation algorithm (now O(log n)), but rather the maximum out-degree (O(α + log n)) of the resulting orientation. However, both of these updated results have already been obsoleted by one due to Peleg and Solomon [12], which maintains an (1 + ε)-approximate matching in O(α) time without the use of an orientation algorithm. Since the maximum out-degree is always at least α − 1 in any orientation, it seems that any matching algorithm that employs an orientation algorithm will also require new ideas to push its time complexity to o(α).