An Adaptive Version of Brandes' Algorithm for Betweenness Centrality

Betweenness centrality---measuring how many shortest paths pass through a vertex---is one of the most important network analysis concepts for assessing the relative importance of a vertex. The well-known algorithm of Brandes [J. Math. Sociol.~'01] computes, on an $n$-vertex and $m$-edge graph, the betweenness centrality of all vertices in $O(nm)$ worst-case time. In later work, significant empirical speedups were achieved by preprocessing degree-one vertices and by graph partitioning based on cut vertices. We contribute an algorithmic treatment of degree-two vertices, which turns out to be much richer in mathematical structure than the case of degree-one vertices. Based on these three algorithmic ingredients, we provide a strengthened worst-case running time analysis for betweenness centrality algorithms. More specifically, we prove an adaptive running time bound $O(kn)$, where $k


Introduction
One of the most important building blocks in network analysis is to determine a vertex's relative importance in the network. A key concept herein is betweenness centrality as introduced in 1977 by Freeman [10]; it measures centrality based on shortest paths. Intuitively, for each vertex, betweenness centrality counts the (relative) number of shortest paths that pass through the vertex. A straightforward algorithm for computing the betweenness centrality on undirected (unweighted) n-vertex graphs runs in O(n 3 ) time, and improving this to O(n 3−ε ) time for any ε > 0 would break the so-called APSP-conjecture [1]. In 2001, Brandes [5] presented the to date theoretically fastest algorithm, improving the running time to O(nm) for graphs with m edges. As many real-world networks are sparse, this is a far-reaching improvement, having a huge impact also in practice. We remark that Newman [20,21] presented a high-level description of an algorithm computing a variant of betweenness centrality which also runs in O(nm) time.
Since betweenness centrality is a measure of outstanding importance in network science, it finds numerous applications in diverse areas, e.g. in social network analysis [21,30] or neuroscience [15,17]. Provably speeding up betweenness centrality computations is the ultimate goal of our research. To this end, we extend previous work and provide a rigorous mathematical analysis that yields a new (parameterized) running time upper bound of the corresponding algorithm.
Our work is in line with numerous research efforts concerning the development of algorithms for computing betweenness centrality, including approximation algorithms [2,11,25], parallel and distributed algorithms [27,29], streaming and incremental algorithms [13,19], and exact [8] and fixed-parameter algorithms [6]. Formally, we study the following problem: The length of the path P is |E(P )|. Adding the edge {v q , v 0 } to P gives a cycle C = v 0 . . . v q v 0 . The distance d G (s, t) between vertices s, t ∈ V (G) is the length of the shortest path between s and t in G. The number of shortest s-t-paths is denoted by σ st . The number of shortest s-t-paths containing some vertex v is denoted by σ st (v). We set σ st (v) = 0 if s = v or t = v (or both).
We set [j, k] := {j, j + 1, . . . , k} and denote for a set X by X i the size-i subsets of X.
Paper outline. The presentation of our algorithm is split into two parts: In Section 2 we present the strategy of our algorithm. Section 3 deals with the main technical challenge of our algorithm, namely how to deal with consecutive degree-two vertices. Some proofs in the latter part are deferred to the appendix. Finally, we conclude in Section 4.

Algorithm Overview
In this section, we review our algorithmic strategy to compute the betweenness centrality of each vertex. Before doing so, since we build on the works of Brandes [5], Baglioni et al. [3], Puzis et al. [24], and Sariyüce et al. [26], we first give the high-level ideas behind their algorithmic approaches. Then, we describe the ideas behind our extension. We assume throughout our paper that the input graph is connected. Otherwise, we can process the connected components one after another.
Existing algorithmic approaches. Brandes [5] developed an O(nm)-time algorithm which essentially runs modified breadth-first searches (BFS) from each vertex of the graph. In each of these modified BFS starting in a vertex s, Brandes' algorithm computes the "effect" that s has on the betweenness centrality values of all other vertices. More formally, the modified BFS starting at vertex s computes for every v ∈ V (G) the value Reducing the number of performed modified BFS in Brandes' algorithm is one way to speed up Brandes' algorithm. To this end, a popular approach is to remove in a preprocessing step all degree-one vertices from the graph [3,24,26]. By repeatedly removing degree-one vertices, whole "pending trees" (subgraphs that are trees and are connected to the rest of the graph by a single edge) can be deleted. Considering a degree-one vertex v, observe that in each shortest path P starting at v, the second vertex in P is the single neighbor u of v. Hence, after deleting v, one needs to store the information that u had a degree-one neighbor. To this end, one uses for each vertex w a counter called Pen[w] (for pending) that stores the number of vertices in the subtree pending on w that were deleted before. In contrast to e. g. Baglioni et al. [3], we initialize for each vertex w ∈ V the value Pen[w] with one instead of zero (so we count w as well). This simplifies most of our formulas. See Figure 1 (Parts (1.) to (3.)) for an example of the Pen[·]-values of the vertices at different points in time. We obtain the following (weighted) problem variant.
The effect of a degree-one vertex to the betweenness centrality value of its neighbor is captured in the next data reduction rule. A second approach to speed up Brandes' algorithm is to split the input graph G into smaller connected components and process them separately [24,26]. This approach is a generalization of the ideas behind removing degree-one vertices and works with cut vertices. The basic observation for this approach is as follows: Consider a cut vertex v such that removing v breaks the graph into two connected components C 1 and C 2 (the idea generalizes to more components). Obviously, every shortest path P in G that starts in C 1 and ends in C 2 has to pass through v. For the betweenness centrality values of the vertices inside C 1 (inside C 2 ) it is not important where exactly P ends (starts). Hence, for computing the betweenness centrality values of the vertices in C 1 , it is sufficient to know which vertices in C 1 are adjacent to v and how many vertices are contained in C 2 . Thus, in a preprocessing step one can just add to C 1 the cut vertex v with Pen[v] being increased by the sum of Pen[·]-values of the vertices in C 2 (see Figure 1 (bottom)). Formally, this is done as follows.

Pen[s] ,
and ignoring all new vertices v i is the same as computing the betweenness centrality in G, that is, Applying the above procedure as preprocessing on all cut vertices and degree-one vertices leaves us with biconnected components that we can each solve independently. We first look at the special case that the connected component (obtained from Lemma 1) is a cycle, then deal with the general, more involved case.

Dealing with Cycles
We now show how to solve Weighted Betweenness Centrality on cycles with a lineartime dynamic programming algorithm. Note that the vertices in the cycle can have different betweenness centrality values as they can have different Pen[·]-values. Proof. We first introduce some notation needed for the proof, then we will show how to compute BC [v] for v ∈ V (C) efficiently. Finally, we prove the running time. By The value W [x i , x j ] is the sum of all Pen-values from x i to x j , clockwise. Further, we denote by ϕ(i) = ( q+1 2 + i) mod(q + 1) the index that is "opposite" to i on the cycle. Note that if ϕ(i) ∈ N, then x ϕ(i) is the unique vertex in C to which there are two shortest paths from x i , one visiting x i+1 mod(q+1) and one visiting x i−1 mod(q+1) . Otherwise, if ϕ(i) ∈ N, then there is only one shortest path from x k to any t ∈ V (C). For the sake of convenience in the next parts of the proof, if ϕ(i) ∈ N, we say that Pen[x ϕ(xi) ] = 0. Further, by ϕ left (i) = ⌈ϕ(i)⌉ − 1 mod(q + 1) we denote the index of the vertex to the left of index ϕ(i) and by ϕ right (i) = ⌊ϕ(i)⌋ + 1 mod(q + 1) the index of the vertex to the right of index ϕ(i).
We now describe the algorithm. For every vertex x k , 0 ≤ k ≤ q, we need to compute We determine these values with a dynamic program.
Also, for every shortest path starting in x ϕ(0) and ending in some . Thus there is no shortest path starting in x ϕ(0) that visits x 0 . Hence, we do not need to consider the cases i = 0 or i = ϕ(0) and we have Hence, there is a unique shortest path from x i to x ϕ left (i) visiting x i+1 mod(q+1) , and there is a unique shortest path from x i to x ϕ right (i) visiting x i−1 mod(q+1) . This gives us that in the equation above, in the first sum, all shortest paths from x i to t ∈ [x ϕ right (i) , x q ] visit x 0 , and in the second sum, all shortest paths from x i to t ∈ [x 1 , x ϕ left (i) ] visit x 0 . If ϕ(x i ) ∈ N, then there are two shortest paths from x i to x ϕ(i) , and one of them visits x 0 . With this we can rewrite the sum as follows: To this end, observe that all shortest paths in C that contain x k as an inner vertex also contain x k+1 as an inner vertex, except for those paths that start or end in x k+1 . Likewise, all shortest paths in C that contain x k+1 as an inner vertex also contain x k as an inner vertex, except for those paths that start or end in x k . Hence, to compute BC[x k+1 ] from BC[x k ], we need to subtract the γ-values for shortest paths starting in x k+1 and visiting x k , and we need to add the γ-values for shortest paths starting in x k and visiting x k+1 . Since by Observation 1 each path contributes the same value to the betweenness centrality as its reverse, it holds With a similar argumentation as above for the computation of BC[x 0 ] one can show that shortest paths starting in x k and visiting x k+1 must end in t ∈ [x k+2 , x ϕ left (k) ], or in x ϕ(k+1) . Shortest paths starting in x k+1 and visiting x k must end in t ∈ [x ϕ right (k+1) , x k−1 ], or in x ϕ(k) . Just as above, for both i = k and i = k + 1, some fixed vertex x j is visited by only half of the shortest paths from x i to x ϕ(i) . With the arguments above we can rewrite Equation (3)

Dealing with Other Biconnected Graphs
Recall that, after our preprocessing on all cut vertices and degree-one vertices, we obtain a graph consisting of biconnected components, each of which can be solved independently. Also, in the previous subsection, we showed how to solve Weighted Betweenness Centrality on cycles. It remains to show how to solve the problem on biconnected graphs that are not cycles (but may contain one).
Remark. Henceforth, in this paper, we assume that we are given a vertex-weighted biconnected graph that is not a cycle.
Outline of the algorithmic approach. Starting with a vertex-weighted biconnected graph, our algorithm focuses on degree-two vertices. In contrast to degree-one vertices, degree-two vertices can lie on shortest paths between two other vertices. Moreover, different degree-two vertices on the same shortest path can have different betweenness centrality values (see Figure 2 for an example). This makes degree-two vertices harder to handle: Removing a degree-two vertex v in a similar way as done with degree-one vertices (see Reduction Rule 2.1) potentially affects many other shortest paths that neither start nor end in v. Thus, we treat degree-two vertices differently: Instead of removing vertices one-by-one, we process multiple degree-two vertices at once and exploit that consecutive degree-two vertices share many shortest paths they lie on. To this end we introduce the notion of maximal induced paths. Definition 1. Let G be a graph. A path P = v 0 . . . v ℓ is a maximal induced path in G if ℓ ≥ 2 and the inner vertices v 1 , . . . , v ℓ−1 all have degree two in G, but the endpoints v 0 and v ℓ do not, that is, In a nutshell, our algorithm treats each biconnected component of the input graph in the following three stages (compare with Algorithm 1): 1. For all pairs s, t of vertices of degree at least three, precompute d G (s, t) and σ st , and initialize Inc[s, t] (see Lines 3 to 6).
2. Compute betweenness centrality values for paths starting and ending in maximal induced paths and store them in Inc[·, ·], considering two cases (see Lines 11 to 16): -both endpoints of the path are in the same maximal induced path; -the endpoints are in two different maximal induced paths.
3. In a postprocessing step, compute the betweenness centrality for all remaining paths (at least one endpoint is of degree at least three) and incorporate the values stored in Inc[·, ·] (see Lines 17 to 18).
Algorithm 1: Algorithm for computing betweenness centrality of a biconnected graph that is not a cycle. Input: An undirected biconnected graph G with vertex weights Pen: V (G) → N. Output: The betweenness centrality values of all vertices.
), see Section 3 /* deal with the case t ∈ V =2 (P max 2 ), see Section 3.1 */ 12 foreach y 0 y 1 . . . y r = P max 19 return BC. . The former affect the betweenness centrality value of x 2 , but not of x 3 ; the latter affect the betweenness centrality value of x 3 , but not of x 2 . Hence, most, but not all, of the paths traversing through x 2 also affect the betweenness centrality value of x 3 . Note that this difference cannot be decided locally within the maximal induced path, but can have an arbitrary effect on the difference arbitrarily far away in the graph.
In this example graph, one could add more and more "d-vertices" (the figure shows d 1 -d 7 ) to further increase the difference in the betweenness centrality values of x 2 and x 3 .
Note that in a biconnected graph that is not a cycle, every degree-two vertex is an inner vertex of a maximal induced path. If some degree-two vertex v was not contained in a maximal induced path, then v would be contained in a cycle that contains exactly one vertex u that is of degree at least three. But then u is a cut vertex and the graph would not be biconnected; a contradiction. The remaining part of the algorithm deals with maximal induced paths. Note that if the (biconnected) graph is not a cycle, then all degree-two vertices are contained in maximal induced paths: Using standard arguments, we can show that the number of maximal induced paths is upperbounded by the minimum of the feedback edge number k of the input graph and the number n of vertices. Moreover, one can easily compute all maximal induced paths in linear-time (see Line 2 of Algorithm 1).

Lemma 2. Let G be a graph with feedback edge number k that does not contain degree-one vertices.
Then G contains at most min{n, 2k} vertices of degree at least three and at most min{n, 3k} maximal induced paths.
Proof. Recall that our graph is biconnected. Thus v∈V (G) deg(v) = 2m = 2(n − 1 + k), and Solving for |V ≥3 (G)| gives us that there are at most 2k − 2 vertices of degree at least three.
It follows that there are at most 3k paths whose endpoints are in V ≥3 (G), hence |P max | ≤ 3k − 3. Clearly, for both the number of vertices of degree at least three and number of maximal induced paths, n is also a valid upper bound. Proof. Iterate through all vertices v ∈ V (G). If v ∈ V =2 (G), then iteratively traverse the two edges incident to v to discover adjacent degree-two vertices until finding endpoints v ℓ , v r ∈ V ≥3 (G).
If v ℓ = v r , then we found a cycle which can be ignored. Otherwise, we have a maximal induced path P max = v ℓ . . . v r , which we add to P max .
Note that every degree-two vertex is contained either in exactly one maximal induced path or in exactly one cycle. Hence, we do not need to reconsider any degree-two vertex found in the traversal above and we can find all maximal induced paths in O(m + n) time.
Our algorithm processes the maximal induced paths one by one (see Lines 3 to 18). This part of the algorithm requires pre-and postprocessing (see Lines 3 to 10 and Lines 17 to 18 respectively). In the preprocessing, we initialize tables that are frequently used in the main part (of Section 3). The postprocessing computes the final betweenness centrality values of each vertex as this computation is too time-consuming to be executed for each maximal induced path. When explaining our basic ideas, we will first present the postprocessing as this explains why certain values will be computed during the algorithm.
Recall that we want to compute (1)). Using the following observations, we split Equation (1) into different parts.
Observation 2. Let G be a biconnected graph with at least one vertex of degree at least three.
Proof. The first two sums cover all pairs of vertices in which at least one of the two vertices is of degree at least three. The other two sums cover all pairs of vertices which both have degree two. As all vertices of degree two must be part of some maximal induced path, we have V =2 (G) = V =2 ( P max ). Two vertices of degree two can thus either be in two different maximal induced paths (third sum) or in the same maximal induced path (fourth sum).
In the remaining graph, by Lemma 2, there are at most O(min{k, n}) vertices of degree at least three and at most O(k) maximal induced paths. This implies that we can afford to run the modified BFS (similar to Brandes' algorithm) from each vertex s ∈ V ≥3 (G) in O(min{k, n}·(n+k)) = O(kn) time. This computes the first summand and, by Observation 1, also the second summand in Observation 2. However, we cannot afford to run such a BFS from every vertex. Thus, we need to compute the third and fourth summand differently.
To this end, note that σ st (v) is the only term in γ(s, t, v) that depends on v. Our goal is to precompute γ(s, t, v)/σ st (v) = Pen[s] · Pen[t]/σ st for as many vertices as possible. Hence, we store precomputed values in a table Inc[·, ·] (see Lines 6,14 and 16). Then, we plug this factor into the next lemma which provides our postprocessing.

Lemma 4. Let s be a vertex and let
Proof. This proof generally follows the structure of the proof by Brandes [5, Theorem 6, Corollary 7], the main difference being the generalization of the distance function to an arbitrary function f .
Analogously to Brandes we define σ st (v, w) as the number of shortest paths from s to t that contain the edge {v, w}, and S s (v) as the set of successors of a vertex v on shortest paths from s, that is, For the sake of readability we also define χ sv = t∈V (G) f (s, t) · σ st (v). We will first derive a series of equations that show how to compute χ sv . Afterwards we justify Equations (4) and (5).
We will now show that Equations (4) and (5) are correct. All other equalities are based on simple arithmetics. To see that Equation (4) is correct, observe that each shortest path from s to any To see that Equation (5) is correct, observe the following: First, note that the number of shortest paths from s to t that contain a vertex v is second, note that the number of shortest st-paths that contain an edge {v, w}, w ∈ S s (v), is and third, note that the number of shortest sw-paths that contain v is equal to the number of shortest sv-paths. The combination of these three observations yields We next show how to compute χ sv for all v ∈ V in O(m + n · τ ) time. First, order the vertices in non-increasing distance to s and compute the set of all successors of each vertex in O(m) time using breadth-first search. Note that the number of successors of all vertices is at most m since each edge defines at most one successor-predecessor relation. Then compute χ sv for each vertex by a dynamic program that iterates over the ordered list of vertices and computes This concludes the proof.
The proof of Lemma 4 provides us with an algorithm. Our goal is then to only start this algorithm from few vertices, specifically the vertices of degree at least three (see Line 18 of Algorithm 1). Since the term τ in the above lemma will be constant, we obtain a running time of O(kn) for running this postprocessing on all vertices of degree at least three. The most intricate part will be to precompute the factors in Inc[·, ·] (see Lines 14 and 16 of Algorithm 1). We defer the details to Sections 3.1 and 3.2. In these parts, we need the tables W left and W right . These tables store values depending on the maximal induced path a vertex is in. More precisely, for a vertex x i in a maximal induced path The reason for having these tables is easy to see: Assume for the vertex x k ∈ P max that the shortest paths to t / ∈ V (P max ) leave P max through x 0 . Then, it is equivalent to just consider the shortest path(s) starting in x 0 and simulate the vertices between x k and x 0 in P max by "temporarily increasing" Pen

Dealing with maximal induced paths
In this section, we focus on degree-two vertices contained in maximal induced paths. Recall that the goal is to compute the betweenness centrality C B (v) (see Equation (1)) for all v ∈ V (G) in O(kn) time. In the end of this section, we finally prove our main theorem (Theorem 1). Figure 3 shows the general proof structure of the main theorem. Based on Observation 2, which we use to split the sum in Equation (1) in the definition of Weighted Betweenness Centrality, we compute C B (v) in three steps. By starting a modified BFS from vertices in V ≥3 (G) similarly to Baglioni et al. [3] and Brandes [5], we can compute In the next two subsections, we show how to compute the remaining two summands given in Observation 2 (i.e., we prove Propositions 2 and 3). In the last subsection, we prove Theorem 1.

Paths with endpoints in different maximal induced paths
In this subsection, we look at shortest paths between pairs of maximal induced paths P max 1 = x 0 . . . x q and P max 2 = y 0 . . . y r , and how to efficiently determine how these paths affect the betweenness centrality of each vertex.  at least one endpoint of degree at least three Figure 3: Structure of how the proof of Theorem 1 is split into different cases. By "paths" we mean maximal induced paths. The first layer below the main theorem specifies the positions of the endpoints s and t, whereas the second layer specifies the position of the vertex v, for which the betweenness centrality is computed. The third layer displays further lemmata used to prove the corresponding lemma above. Proofs of lemmata marked with an asterisk are deferred to the appendix.
In the proof of Proposition 2, we consider two cases for every pair P max 1 = P max 2 ∈ P max of maximal induced paths: First, we look at how the shortest paths between vertices in P max 1 and P max 2 affect the betweenness centrality of those vertices that are not contained in the two maximal induced paths, and second, how they affect the betweenness centrality of those vertices that are contained in the two maximal induced paths. Finally, we prove Proposition 2.
Throughout the following proofs, we will need the following definitions (see Figure 4 for an illustration). Let t ∈ P max

Vertices outside of the maximal induced paths
We now show how shortest paths between two fixed maximal induced paths P max 1 and P max 2 affect the betweenness centrality of vertices that are not contained in P max Proof. We fix P max 1 = P max 2 ∈ P max with P max 1 = x 0 . . . x q and P max 2 = y 0 . . . y r . We show how to compute s∈V =2 (P max ). Afterwards, we analyze the running time.
By definition of x left t , x mid t and x right t we have By definition of maximal induced paths, every shortest path from s ∈ V =2 (P max 1 ) to t visits either y 0 or y r . For ψ ∈ {x 0 , x q } let S(t, ψ) be a maximal subset of {y 0 , y r } such that for each ϕ ∈ S(t, ψ) there is a shortest st-path via ψ and ϕ. An example for this notation is given in Figure 5. Then, for s ∈ X left t , all st-paths visit x 0 and ϕ ∈ S(t, x 0 ). Hence, we have that σ st = ϕ∈S(t,x0) σ x0ϕ and σ st (v) = ϕ∈S(t,x0) σ x0ϕ (v). Analogously, for s ∈ X right t we have that σ st = ϕ∈S(t,xq) σ xqϕ and σ st (v) = ϕ∈S(t,xq) σ xq ϕ (v). Paths from t to x mid t may visit x 0 and ϕ ∈ S(t, x 0 ) or x q and ϕ ∈ S(t, x q ). Hence, σ tx mid t = ϕ∈S(tx0) σ x0ϕ + ϕ∈S(t,xq) σ xqϕ . The equality holds analogously for σ tx mid t (v). With this at hand, we can simplify the computation of the first sum of Equation (7): Analogously, and With this we can rewrite Equation (7) to By joining values σ x0ϕ (v) and σ xqϕ (v) we obtain =: Note that we define X 1 and X 2 to be the terms in the parentheses before the two sums. We need to increase the betweenness centrality of all vertices on shortest paths from s to t via x 0 by the value of Term (11), and those shortest paths via x q by the value of Term (12). By Lemma 4, increasing Inc[s, t] by some value A ensures the increment of the betweenness centrality of v by A · σ st (v) for all vertices v that are on a shortest path between s and t. Hence, increasing Inc[x 0 , ϕ] for every ϕ ∈ S(t, x 0 ) by X 1 is equivalent to increasing the betweenness centrality of v by the value of Term (11). Analogously, increasing Inc[x q , ϕ] for every ϕ ∈ S(t, x q ) by X 2 is equivalent to increasing the betweenness centrality of v by the value of Term (12).
We now have incremented Inc[ψ, ϕ] for ψ ∈ {x 0 , x q } and ϕ ∈ {y 0 , y r } by certain values, and we have shown that this increment is correct if the shortest ψϕ-paths do not visit inner vertices of P max 1 or P max 2 . We still need to show that (1) increasing Inc[ψ, ϕ] does not affect the betweenness centrality of ψ or ϕ, and that (2)  For the first point, recall that for each s, t ∈ V ≥3 (G) the betweenness centrality of v ∈ V (G) is increased by Inc[s, t] · σ st (v). But since σ ψϕ (ψ) = σ ψϕ (ϕ) = 0, increments of Inc[ψ, ϕ] do not affect the betweenness centrality of ψ or ϕ.
For the second point, suppose that there is a shortest ψϕ-path that visits inner vertices of P max 2 . Letφ = ϕ be the second endpoint of P max , ϕ), and for all inner vertices y i of P max 2 , that is, for all y i with 1 ≤ i < r, it holds that Hence, there are no shortest y i ψ-paths that visit ϕ, and consequently Inc[ψ, ϕ] will not be incremented. The same argument holds if there is a shortest ψϕ-path that visits inner vertices of P max

Vertices inside the maximal induced paths
We now consider how shortest paths between pairs of two maximal induced paths P max 1 = P max 2 affect the betweenness centrality of their vertices.
When iterating through all pairs P max 1 = P max 2 ∈ P max , one will encounter the pair (P max 1 , P max 2 ) and its reverse (P max 2 , P max 1 ). Since our graph is undirected, instead of looking at the betweenness centrality of the vertices in both maximal induced paths, it suffices to consider only the vertices inside the second maximal induced path of the pair. This is shown in the following lemma.

γ(s, t, v)
is equivalent to computing for every P max 1 = P max 2 ∈ P max and for each v ∈ V (P max Since the proof of Lemma 7 is rather tedious and not special in terms of employed methods, we defer it to Appendix B.1. With this at hand we can show how to compute X v for each v ∈ V (P max 2 ), for a pair P max 1 = P max 2 ∈ P max of maximal induced paths. To this end, we show the following lemma.
Again, due to being tedious, we defer the proof of Lemma 8 to Appendix B.2. The high-level approach has two steps: First, we show how to compute the value s∈V =2 (P max 1 ) γ(s, t, v) for a fixed t ∈ V =2 (P max 2 ) and v ∈ V (P max 2 ) in constant time; here we use that the values listed in the lemma are known. Second, we use a dynamic program to compute for all v ∈ V (P max 2 ) the value of Sum (14) in O(|V (P max 2 )|) time, using the fact that the difference between the sums of two adjacent v, v ′ ∈ V (P max 2 ) can be computed in constant time.
We are now ready to combine Lemmata 6 to 8 to prove Proposition 2. As mentioned above, to keep the proposition simple, we assume that the values Inc[s, t] · σ st (v) can be computed in constant time for every s, t ∈ V ≥3 (G) and v ∈ V (G). In fact, these values are computed in the last step of the algorithm (see Lines 17 and 18 in Algorithm 1 and Lemma 4).

Proposition 2 (Restated). In O(kn) time one can compute the following values for all
). Given the values ρ i of Lemma 8 we can compute the values X v defined in Equation (13) for v = y i ∈ V (P max 2 ) as follows: Sum (15) must be computed for every pair P max 1 = P max 2 ∈ P max . Thus, overall, we require time, since there are at most O(k) maximal induced paths and at most n vertices in all maximal induced paths combined.

Paths with endpoints in the same maximal induced path
We now look at shortest paths starting and ending in a maximal induced path P max = x 0 . . . x q and show how to efficiently compute how these paths affect the betweenness centrality of all vertices in the graph. The goal is to prove the following: In O(kn) time one can compute the following for all v ∈ V (G): Figure 6: A maximal induced path that affects the betweenness centralities of vertces outside of P max , such as v. Clearly, if there is a shortest st-path visiting v (thick edge), then there exists a shortest x 0 x q -path visiting v (dashed edge). On an intuitive level, we store the information of the vertices inside of P max in the table entry Inc[x 0 , x q ].
We start off by noting the following: Let v ∈ V (G) and let P max = x 0 . . . x q be a maximal induced path. Then For the sake of readability we set [x p , x r ] := {x p , x p+1 , . . . , x r }, p < r. We will distinguish between two different cases that we then treat separately: We will show that both cases can be solved in overall O(|V (P max )|) time for P max . Doing this for all maximal induced paths results in a time of O( P max ∈P max |V =2 (P max )|) = O(n). In the calculations we will distinguish between the two main cases-all shortest x i x j -paths are fully contained in P max , or all shortest x i x j -paths leave P max -and the corner case that there are some shortest paths inside P max and some that partially leave it.
We will now compute the value for all paths that only consist of vertices in P max , that is, we will compute for each x k with i < k < j the term with a dynamic program in O(|V (P max )|) time. Since i < k < j, by Observation 1, this can be simplified to Lemma 9. Let P max = x 0 . . . x q be a maximal induced path. In O(|V (P max )|) time, one can compute the following for all x k with 0 ≤ k ≤ q: The main idea of the dynamic program is the following: Given the value of α x k , one can compute its difference to α x k+1 in constant time, once W left , W right are precomputed (see Lines 7 to 10 in Algorithm 1). These tables can be computed in O(|V (P max )|) time as well. The proof of Lemma 9 is deferred to Appendix C.1. Now we need to show how to compute the value for all paths that (partially) leave P max . See Figure 6 for an example of such a path.
Note that in the postprocessing (see Lines 17 and 18 in Algorithm 1) the betweenness centrality value of each vertex v is increased by Inc[s, t] · σ st (v) for each pair of vertices s, t ∈ V ≥3 (G). The proof is split into two cases: Lemma 9). The first case makes use of the postprocessing step (see Lines 17 to 18 in Algorithm 1) which was used in an analogous way in the proof of Lemma 6, while the second case uses a dynamic programming approach similar to the one used in the proof of Lemma 9. The proof details can be found in Appendix C.2.

Postprocessing and algorithm summary
We are now ready to combine all parts and prove our main theorem. Proof. As shown in Proposition 1, if the input graph G is a cycle, then we are done.
We show that Algorithm 1 computes the value for all v ∈ V (G) in O(kn) time and space. We use Observation 2 to split the sum as follows.
By Propositions 2 and 3, we can compute the third and fourth summand in O(kn) time provided that Inc[s, t] · σ st (v) is computed for every s, t ∈ V ≥3 (G) and every v ∈ V (G) in a postprocessing step (see Lines 11 to 16). We incorporate this postprocessing into the computation of the first two summands in the equation, that is, we next show that for all v ∈ V (G) the following value can be computed in O(kn) time: To this end, observe that the above is equal to vertices of degree at least three. Thus, altogether, the algorithm needs O(min{n, k} · m) = O(min{n, k} · (n + k)) = O(kn) time. The precomputations in Lines 3 to 6 require Θ(kn) space. As the running time is an upper bound on the space complexity, Algorithm 1 requires Θ(kn) space overall.

Conclusion
Lifting the processing of degree-one vertices due to Baglioni et al. [3] to a technically much more involved processing of degree-two vertices, we derived a new algorithm for Betweenness Centrality running in O(kn) worst-case time (k is the feedback edge number of the input graph). Our work focuses on algorithm theory and contributes to the field of adaptive algorithm design [9] as well as to the recent "FPT in P" field [12]. It would be of high interest to identify structural parameterizations "beyond" the feedback edge number that might help to get more results in the spirit of our work. In particular, extending our algorithmic approach and mathematical analysis with respect to the treatment of twin vertices [24,26] might help to get a running time bound involving the vertex cover number of the input graph. As for practical relevance, we firmly believe that a running time of O(kn) as we proved can yield improved performance for some real-world networks. What remains unclear, however, is whether the constants hidden in the O-notation or the non-linear space requirements of our approach can be avoided.

A Notation for proofs in appendix
For the following proofs we will introduce a lot of auxiliary notation. We provide Table 1 as a reference to the definitions of the notations. Table 1: A reference to the notation used in the Appendix. We assume P max = P max 1 = x 0 . . . x q and P max 2 = y 0 . . . y r .

Symbol
Definition the set of vertices of degree two in G; V ≥3 (G) the set of vertices of degree at least three in G; a table of size |V ≥3 (G)| × |V (G)| in which intermediary betweenness centrality values are stored; P max the set of all maximal induced paths; , the maximal subset of {y 0 , y r } = V ≥3 (|P max 2 |) such that for each ϕ ∈ S(t, ψ) there is a shortest st-path via ψ and ϕ; X v see Equation (13); λ(y k , y i ) = s∈V =2 (P max 1 ) γ(s, y k , y i ), for 0 ≤ i ≤ r, 1 ≤ k < r, and s ∈ V =2 (P max 1 ); η(y k , ϕ, ψ) is 1 if there is a shortest path from y k to ψ ∈ {x 0 , x q } to ϕ ∈ {y 0 , y r }, 0 otherwise; ω i for 0 < k, i < r, y r if k < i, y 0 if k > i; κ(y k , ω i ) see Equation (26); κ(y k , y r ) + r−1 k=i+1 κ(y k , y 0 ), for 0 < i < r;

B Proofs of Lemmata 7 and 8 B.1 Proof of Lemma 7
Lemma 7 (Restated). Computing for every pair P max 1 = P max 2 ∈ P max and for each ver- is equivalent to computing for every P max Proof. We will first assume that V (P max 1 ) ∩ V (P max 2 ) = ∅ for every P max 1 = P max 2 ∈ P max , and will discuss the special case V (P max , the betweenness centrality of v is increased by and by Observation 1 this is equal to Analogously, for every w ∈ V (P max 1 ), the betweenness centrality of v is increased by γ(s, t, w).
Thus, computing Sum (19) for v ∈ V (P max 2 ) for every pair P max 1 = P max 2 ∈ P max is equivalent to computing Sum (17) for v ∈ V (P max 1 ) ∪ V (P max 2 ) for every pair P max 1 = P max 2 ∈ P max , since when iterating over pairs of maximal induced paths we will encounter both the pairs (P max Proof. We first show how to compute s∈V =2 (P max 1 ) γ(s, t, v) for fixed t ∈ V =2 (P max 2 ) and v ∈ V (P max 2 ) in constant time when the values listed above are known. Then we present a dynamic program that computes for all v ∈ V (P max 2 ) the value of Sum (20) in O(|V (P max 2 )|) time. Let P max 1 = x 0 . . . x q and let P max For easier reading, we define for 0 ≤ i ≤ r and for 1 ≤ k < r Recall that all shortest paths from y k to s ∈ X left y k visit x 0 and all shortest paths from y k to s ∈ X right y k visit x q . Recall also that for each y k there may exist a unique vertex x mid y k to which there are shortest paths via x 0 and via x q .
With this at hand, we have Next, we rewrite λ in such a way that we can compute it in constant time. To this end, we need to make the values σ independent of s and y i . To this end, note that if k < i, then y i is visited only by shortest paths from y k to s ∈ V =2 (P max 1 ) that also visit y r . If k > i, then y i is only visited by paths that also visit y 0 . Hence, we need to know whether there are shortest paths from y k to some endpoint of P max 1 via either y 0 or y r . For this we define η(y k , ϕ, ψ), which, informally speaking, tells us whether there is a shortest path from y k to ψ ∈ {x 0 , x q } via ϕ ∈ {y 0 , y r }. Formally, Since d G (s, t) is given for all s, t ∈ V ≥3 (G), the values η can be computed in constant time. We now show how to compute σ sy k (y i )/σ sy k . Let ω i = y r if k < i, and ω i = y 0 if k > i. As stated above, for y i to be on a shortest path from y k to s ∈ V =2 (P max 1 ), the path must visit ω i . If s is in X left y k , then the shortest paths enter P max 1 via x 0 , and σ sy k (y i )/σ sy k = σ x0y k (y i )/σ x0y k . Note that there may be shortest sy k -paths that pass via y 0 and sy k -paths that pass via y r . Thus we have With σ x0y k (y i ) we count the number of shortest x 0 y k -paths visiting y i . Note that any such path must visit ω i . If there is such a shortest path visiting ω i , then all shortest x 0 y k -paths visit y i , and since there is only one shortest ω i y k -path, the number of shortest x 0 y k -paths visiting ω i is equal to the number of shortest x 0 ω i -paths, which is σ x0ωi . If s ∈ X right y k , then Shortest paths from y k to x mid y k may visit any ϕ ∈ {y 0 , y r } and ψ ∈ {x 0 , x q }, and thus Observe that (1) the values of Equations (23) to (25) can be computed in constant time, since the values σ st are known for s, t ∈ V ≥3 (G), and (2) the values σ sy k (y i ) and σ sy k are independent of s for s ∈ X left y k and for s ∈ X right η(y k , ω i , x 0 )σ x0ωi η(y k , y 0 , x 0 )σ x0y0 + η(y k , y r , x 0 )σ x0yr η(y k , ω i , x q )σ xqωi η(y k , y 0 , x q )σ xqy0 + η(y k , y r , x q )σ xq yr . Pen[s] · η(y k , y r , x 0 )σ x0yr η(y k , y 0 , x 0 )σ xqy0 + η(y k , y r , x 0 )σ xqyr + s∈X right y k Pen[s] · η(y k , y r , x q )σ xq yr η(y k , y 0 , x q )σ xqy0 + η(y k , y r , x q )σ xq yr = κ(y k , y r ).

C Proofs of Lemmata 9 and 10
For the proofs of Lemmata 9 and 10 we first make two auxiliary observations and introduce some additional notation.
Observation 4. Let P max = x 0 . . . x q be a maximal induced path and let 0 ≤ i < j ≤ q. Then Proof. The correctness of (i) is clear. For (ii), note that the claimed equation is equivalent Observation 5. Let P max = x 0 . . . x q be a maximal induced path, let 0 ≤ i < j ≤ q, and let v ∈ V (G). Then where Proof. Most cases are self-explanatory. The denominator σ x0xq + 1 is correct since there are σ x0xq shortest paths from x 0 to x q (and therefore σ x0xq shortest paths from x i to x j that leave P max ) and one shortest path from x i to x j within P max . Note that if there are shortest paths that are not contained in P max , then d G (x 0 , x q ) < q and therefore P max is not a shortest x 0 x q -path.
Definition 2. Let P max = x 0 . . . x q be a maximal induced path and let 0 ≤ i ≤ q. Then we define

C.1 Proof of Lemma 9
Lemma 9 (Restated). Let P max = x 0 . . . x q be a maximal induced path. Then, in O(|V (P max )|) time, one can compute the following for all x k with 0 ≤ k ≤ q: Proof. We construct a dynamic program, then we show that it is solvable in O(|V (P max )|) time.
Note that 1 ≤ i < k. Thus for k = 0 we have This will be the base case of the dynamic program. For every vertex x k with 1 ≤ k < q it holds that Similarly, for x k−1 with 1 < k ≤ q it holds that γ(x i , x k , x k−1 ).
Next, observe that any path from x i to x j with i ≤ k − 2 and j ≥ k + 1 visiting x k also visits x k−1 and vice versa. Substituting this into the equations above yields γ(x i , x k , x k−1 ). Now we prove that j∈[k+1,q−1] γ(x k−1 , x j , x k ) and i∈ [1,k−2] γ(x i , x k , x k−1 ) can be computed in constant time once W left and W right are precomputed (see Lines 7 to 10 in Algorithm 1). These tables can be computed in O(|V (P max )|) time as well. For the sake of convenience we say that γ(x i , x j , x k ) = 0 if i or j are not integral or are not in [ Herein we use the notation introduced in Definition 2. By (k − 1) + mid / ∈ Z we mean to say that (k − 1) + mid is not integral. Analogously, i∈ [1,k−2] γ(x i , x k , x k−1 ) = i∈ [1,k−2] Pen[ This completes the proof since (k − 1) + mid , k − mid , every entry in W [·], and all other variables in the equation above can be computed in constant time once W left [·] is computed. Thus, computing α xi for each vertex x i in P max takes constant time. Hence, the computations for the whole maximal induced path P max take O(|V (P max )|) time.

C.2 Proof of Lemma 10
Lemma 10 (Restated). Let P max = x 0 x 1 . . . x q be a maximal induced path. Then, assuming that Inc[s, t] · σ st (v) can be computed in constant time for some s, t ∈ V ≥3 (G), one can compute in O(|V (P max )|) time the following for all v ∈ V (G) \ [x i , x j ]: Proof. We first show how to compute β v for all v / ∈ V (P max ) and then how to compute β v for all v ∈ V (P max ) \ [x i , x j ] in the given time.
As stated above, the distance from x i to x i + mid (if existing) is the boundary such that all shortest paths to vertices x j with j > i + mid leave P max and the unique shortest path to any x j with i < j < i + mid is x i x i+1 . . . x j . Thus we can use Observations 4 and 5 to show that for each v / ∈ P max and each fixed Due to the postprocessing (see Lines 17 and 18 in Algorithm 1) it is sufficient to add X to Inc[x 0 , x q ]. This ensures that X · σ x0xq (v) is added to the betweenness centrality of each vertex v / ∈ V (P max ). Note that if X > 0, then d G (x 0 , x q ) < q and thus the betweenness centrality of any vertex v ∈ V (P max ) is not affected by Inc[x 0 , x q ].
Next, we will compute β v for all vertices v ∈ V (P max ) (recall that v / ∈ [x i , x j ]). We start with the simple observation that all paths that leave P max at some point have to contain x 0 . Thus β x0 is equal to X by Equation (28). We will use this as the base case for a dynamic program that iterates through P max and computes β x k for each vertex x k , k ∈ [0, q], in constant time.
Furthermore, observe that every st-path with s, t = x k , x k+1 that contains x k also contains x k+1 , and vice versa. Thus we can conclude that .
It remains to show that the sums ( * ) and ( * * ) can be computed in constant time once W left and W right are computed. Using Observations 4 and 5 we get that Pen[ Since all variables in these two equalities can be evaluated in constant time, this concludes the proof.