Efficiently Computing the Shapley Value of Connectivity Games in Low-Treewidth Graphs

The Shapley value is the solution concept in cooperative game theory that is most used in both theoretical as practical settings. Unfortunately, computing the Shapley value is computationally intractable in general. This paper focuses on computing the Shapley value of (weighted) connectivity games. For these connectivity games, that are defined on an underlying (weighted) graph, computing the Shapley value is #P-hard, and thus (likely) intractable even for graphs with a moderate number of vertices. We present an algorithm that can efficiently compute the Shapley value if the underlying graph has bounded treewidth. Next, we apply our algorithm to several real-world (covert) networks. We show that our algorithm can compute exact Shapley values for these networks quickly, whereas in prior work these values could only be approximated using a heuristic method. Finally, it is shown that our algorithm can also compute the Shapley value time efficiently for several larger (artificial) benchmark graphs from the PACE 2018 challenge.


Introduction
Motivated by the need to identify important vertices in networks (graphs), many measures for ranking vertices have been suggested.Among these are the classical centrality measures, such as betweenness, closeness and degree (see e.g., Wasserman and Faust, 1994).However, the drawback is that all these measures only take the structure of the network into account.In light of this, game-theoretic centrality measures have received considerable interest.These measures take not only the structure of the network into account, but enables also to include special information with respect to individuals and links in the network.Further, such a measure takes also into account the coalitional strength of members in the network.
The Shapley value (Shapley, 1953) is most used as centrality measure in these situations.This is not surprising since the Shapley value satisfies intuitive properties (cf.Shapley, 1953;Young, 1985) that are also considered as fair in many situations in practice (e.g., airport landing fees (Littlechild and Owen, 1973), water transportation (Deidda et al., 2009), genetics (Moretti et al., 2007) and terrorism (Lindelauf et al., 2013)).More applications of the Shapley value in different fields can be found in the survey of Moretti and Patrone (2008).
The biggest challenge in applying the Shapley value to real-world applications is the time required to compute it, which generally increases exponentially with the number of players.More precisely, for many games it can be shown that computing the Shapley value is a #P-hard problem (Faigle and Kern, 1992;Michalak et al., 2013a,b).
In this paper we focus on the Shapley value for network games in which the vertices are associated with players.In particular we consider connectivity games, introduced by Amer and Giménez (2004).These are {0, 1}-valued games in which a coalition has the value 1 if the subgraph induced by this coalition is connected, and has value 0 otherwise.In a vertex-weighted connectivity game, introduced by Lindelauf et al. (2013), the value equals the sum of the vertex weights of a coalition that induces a connected subgraph, and 0 if the subgraph is not connected.
Lindelauf et al. studied these centrality measures in the context of identifying the most important vertices in terrorist networks (Lindelauf et al., 2013;van Campen et al., 2017).They considered two networks: one (due to Koschade (2006)) consisting of 17 terrorists involved in a 2002 bombing in Bali, the second (due to Krebs, 2002) consisting of 69 terrorists involved in planning and executing the 9/11 attacks.Whereas for the first network they were able to compute the exact Shapley values, for the second networks this was infeasible and they considered only the part of the network made up by the 19 hijackers that actually carried out the attack.This network in shown in Figure 1.Michalak et al. (2013b) showed that computing the Shapley value for the unweighted game is unfortunately #P-hard.As such, it is unlikely that an efficient algorithm for computing these values exists.On the other hand, Michalak et al. also proposed an algorithm that is slightly more efficient than the Fig. 1: Graph showing the connections between the 19 hijackers that carried out the 9/11 attacks.Vertices are coloured according to the flights they were on.Note that the full network consists of 69 vertices.
brute-force approach used by Lindelauf et al., called FasterSVCG.Using this algorithm, the authors computed Shapley values for a larger version of the 9/11 network, with 36 vertices (corresponding to the hijackers and some key accomplices).Their approach, rather than considering all 2 |V | coalitions, considers only the connected coalitions, of which there may be considerably fewer than 2 |V | .However, in the worst case, the number of connected coalitions may still be exponential.As such, for the full 69-vertex network, running this algorithm is still infeasible.Michalak et al. (2013b) also considered an approximation method based on random sampling and studied its performance on the 36-vertex 9/11 network.van Campen et al. (2017) proposed a different sampling method, structured random sampling, that aims to be more efficient than random sampling.Using this method, they computed approximate Shapley values for the 69-vertex 9/11 network.Unfortunately, neither method comes with any formal guarantees on the quality of the approximation.
While, in general, one should not expect to find an efficient algorithm for computing the exact Shapley values of these games (due to the #P-hardness), we can attempt to exploit the structure that the networks may have in order to obtain more efficient algorithms.
In this paper, we show that the Shapley value (for both the weighted and the unweighted game) can be computed efficiently on graphs of bounded treewidth.Exploiting the fact that a graph has bounded treewidth is a celebrated and widely-used technique from theoretical computer science, and many problems are known to be solvable in polynomial time on graphs of bounded treewidth (Bodlaender, 1997).We use this idea to derive a fixed-parameter tractable algorithm for computing Shapley values.Our result is not merely theoretical: we also provide an implementation and show that it can be used to compute Shapley values for graphs of practical interest.
Treewidth is often said to be a measure of how "tree-like" a graph is.If a graph, on a macroscopic scale, resembles a tree, then treewidth in some sense measures how much it deviates from being a tree locally.The treewidth of a graph is defined in terms of tree decompositions.Such a decomposition is based around a tree, to each vertex of which is associated a set of vertices of the original graph in a way that respects the structure of the graph.The largest number of vertices associated in this way to any given vertex of the tree, determines the treewidth of the graph.We will make this definition more precise in the following section.
Thanks to the simple structure of trees, many NP-hard problems can be solved in polynomial time on trees.Very often, such problems can also be solved in polynomial time on graphs of bounded treewidth: while the best known algorithms for such problems in general require exponential time, we can often construct an algorithm that is only exponential in the treewidth (by doing some exponential computation within each vertex of the tree, which contains a bounded number of vertices of the original graph), and then using the properties of the problem that allow it to be solved in polynomial time on trees to combine the results computed within each tree vertex to a solution for the original problem.
Using our approach, we are able to compute the exact Shapley value for the full 69-vertex network of the 9/11 attacks.We are also able to compute the exact Shapley values for some much larger networks, having up to a thousand vertices.
Of course, our method crucially depends on the network having bounded treewidth.Fortuitously, the network of the 9/11 attacks has a rather low treewidth of only 8.In general one cannot expect social networks to have small treewidth: social networks often have large cliques, and the size of the largest clique forms a lower bound on the treewidth of a graph (see e.g., Adcock et al., 2016, for a study of tree decompositions of social networks).However, terrorist and criminal organizations are often well-served by keeping their networks sparsely connected, as this helps to avoid detection and as such one would not expect large cliques (Lindelauf et al., 2009).As another example of networks that may have low treewidth, the interaction networks in a hierarchical organization would naturally be tree-like.
Our goal is to develop an algorithm that, given a graph G with n = |V | and tree decomposition of G of width tw, computes the Shapley value in time f (tw)n O(1) , where f is some exponential function and n O(1) a (low-degree) polynomial.As such, we hope to "hide" the exponential behaviour of computing the Shapley value in a function that depends only on the treewidth of the graph, and obtain an algorithm whose running time is (for graphs of bounded treewidth) polynomial in n.
Specifically, we show that for a graph G of treewidth tw and a vertex v ∈ V , the Shapley value of the vertex-weighted connectivity game of vertex (player) v can be computed in time 2 O(tw log tw) n 4 log n.Note that our algorithm for computing the Shapley value requires multiplying large (O(n)-bit) integers; this running time is achieved if using the O(n log n)-time algorithm of Harvey and van der Hoeven (2019).Moreover, we usually want to know the Shapley value for all vertices rather than for a specific vertex.Rather than running the previous algorithm n times, we also show that computing the Shapley value for all vertices can be done in the same time, by reusing the intermediate results of previous computations.
For instance, the graph considered by Lindelauf et al. that represents the communications between the perpetrators of the 9/11 attacks, consists of 69 vertices but only has treewidth 8.While evaluating all 2 69 subsets of vertices is clearly infeasible, our algorithm can compute the Shapley value in a couple of seconds thanks to the low treewidth of the graph.
Given a graph G = (V, E), the algorithm of Michalak et al. (2013b) runs in time O((|V | + |E|)|C|) * , where |C| denotes the number of connected induced subgraphs of G.This algorithm, while offering a moderate improvement over the brute-force approach still requires exponential time on almost all interesting classes of graphs.We remark that there exist graphs of low treewidth that have a very large number of connected induced subgraphs (for example, the star on n vertices has treewidth 1 and more than 2 n−1 induced connected subgraphs), while graphs with a small number of induced connected subgraphs also have low treewidth: a graph with at most |C| induced connected subgraphs has treewidth at most 2 log |C| (in fact, pathwidth at most 2 log |C|: if we fix some arbitrary vertex v, then there are at most log |C| vertices at distance exactly r from v).While this bound is tight up to a constant factor (for instance on an n-vertex clique), in many instances the treewidth is much smaller than log |C|.
Treewidth was first considered in the context of connectivity games by Aziz et al. (2009).They considered a game wherein the players are the edges and a winning coalition is one that spans the vertex set.They proved that computing the Banzhaf index can be done in polynomial time for a graph with bounded treewidth, but gave no experimental results and stated as an open problem whether Shapley values could be computed in a similar manner.
Recently, Greco et al. (2017) proposed using treewidth to compute Shapley values for matching games in graphs.In the matching game, the value of a coalition is the size of the maximum matching in the graph induced by that coalition.However, their algorithm is based on a formulation in Monadic Second Order Logic and the application of theoretical frameworks that allow counting of satisfying assignments of MSO formulas.For graphs of bounded treewidth, this yield a polynomial-time algorithm, where the degree of the polynomial may depend on the treewidth.In contrast, the degree of the polynomial in our algorithm is fixed, and only the constant factor in the running time is affected by the treewidth (i.e., we obtain a fixed-parameter tractable algorithm).Moreover, due to the application of these algorithmic metatheorems, their algorithm is not very efficient in practice: Greco et al. (2017) report that, even for a graph of treewidth only 3 with 30 vertices, their implementation (using the MSO solver Sequoia (Langer, 2013)) took nearly 9 minutes to determine the Shapley values.We are able to process much more complex (i.e., higher treewidth) graphs with significantly more vertices in a much shorter time.
Of course, our method crucially depends on being given a tree decomposition of low width.Note that while in general, computing a minimum width tree decomposition is an NP-hard problem, for many graphs of practical interest this can be done efficiently (see e.g., Dell et al., 2018, for an overview of recent -and very competitive -implementations for computing treewidth).
This paper is organized as follows.We will first present some preliminaries on both graph theory and game theoretic centrality, then present the algorithm for computing the Shapley value: we first show how we can compute the Shapley value for one specific vertex (that appears in the root bag of our decomposition), then we show how a (nice) tree decomposition can be modified to quickly compute the Shapley value for all vertices (more quickly than computing it for each vertex individually).We then present an experimental evaluation of our algorithm, evaluating the performance of our network on several benchmark graphs and real-world examples of covert networks.

Graphs and Treewidth
Let G = (V, E) be an undirected graph, where V is its vertex set and E its edge set.To avoid confusion when dealing with multiple graphs (with different vertex sets), we may use the notation V (G) to refer to the vertex set V of G (and similarly, E(G) to refer to its edge set E).Given a subset V ⊆ V , we denote by G[V ] the subgraph of G induced by V .We say that a vertex set S separates vertex sets A, B if any path from a vertex in A to a vertex in B must necessarily include a vertex in S.Where confusion is unlikely, we may write The width of a tree decomposition is max t∈T |X t | − 1, and the treewidth of a graph G is the minimum width taken over all tree decompositions of G. To avoid confusion, from now on we shall refer to the vertices of T as "nodes", and "vertex" shall refer exclusively to vertices of G.
We may designate an arbitrary node of T as root of the tree decomposition.Given a node t ∈ T , we denote by G[t] the subgraph of G induced by X t and the vertices in bags of nodes which are descendants of t in T (i.e.bags corresponding to vertices which can be reached from t without going closer to the root).The following well-known lemma is an important fact, stating that the bags of a tree decomposition are separators: Lemma 1 (equivalent to Cygan et al. (2015), Lemma 7.3) The vertices in X t separate G[t] from the rest of the graph, i.e., for every edge Any tree decomposition can be converted (in linear time) into a decomposition in nice form, that is, each of the nodes t ∈ T is one of four types (Kloks, 1994): -Leaf: t is a leaf of T , and -Introduce: t has a single child node t .X t ⊃ X t and X t contains exactly one vertex v ∈ V (G) that is not in X t , i.e., X t = X t ∪{v}.We say that v is introduced in t. -Forget: t has a single child node t .X t ⊂ X t and X t contains exactly one vertex v ∈ V (G) that is not in X t , i.e., X t = X t \ {v}.We say that v is forgotten in t. -Join: t has exactly two children l, r.Moreover, X l = X r = X t .
If the tree decomposition is given in nice form, we can specify an algorithm simply by specifying how it processes each of these four cases.Moreover, we can assume that the size of a (nice) tree decomposition (i.e. the number of bags) is linear in n (Kloks, 1994).

Shapley Value and Game-Theoretic Centrality
A coalitional game consists of a set of players N (the grand coalition) together with a characteristic function w : 2 N → R such that w(∅) = 0. Given a characteristic function, the Shapley value Φ i (w) of a player i is defined as (Shapley, 1953): In this paper, we consider coalitional games where the players correspond to vertices in a graph.The connectivity game v conn , introduced by Amer and Giménez (2004), is given by the weight function: Note that a coalition consisting of a single player, while connected, has a value of 0. 2013) consider vertex-weighted connectivity games as a generalization of connectivity game.They assume each vertex i has a weight w(i) and the corresponding vertex-weighted connectivity game v wconn2 is defined as follows:

Lindelauf et al. (
In this paper, we give an algorithm for computing the Shapley value associated with v wconn2 , that, as a byproduct, also computes the Shapley value associated with v conn .

The Algorithm
In this section, we present our algorithm for computing the Shapley values of v conn and v wconn2 .We begin by presenting an algorithm that computes the Shapley value for a specific vertex v if a nice tree decomposition which contains v as sole vertex in its root bag is given.We then show how an arbitrary (nice) tree decomposition can be modified to contain any vertex in its root bag, allowing us to evaluate the Shapley value for any vertex.Finally, we show how to avoid the extra factor n that would appear in the running time if we computed the Shapley value for each vertex individually, by reusing parts of the computation.
Theorem 1 Given a graph G = (V, E) and a nice tree decomposition T of width tw such that the root bag X r contains only a single vertex v, φ v (v conn ) and φ v (v wconn2 ) can be computed in time 2 O(tw log tw) n 4 log n.
Pseudocode for our algorithm is given in Listing 1, which uses procedures given in Listings 2, 3, 4 and 5.Note that where we say we update a value, if it has not been set previously, we initialize it to 0.
We give the algorithm for computing φ v (v wconn2 ); the results obtained from this algorithm can also be used to compute φ v (v conn ).We first show that for a given v ∈ V , the (single) value φ v (v wconn2 ) can be computed in time 2 O(tw log tw) n 4 log n.
Using Equation (1) we obtain the following more suitable expression for computing φ v (v wconn2 ), by splitting the summation into different terms, depending on the cardinality k of S: Let S ⊆ V .Since v wconn2 (S) = 0 whenever S induces a subgraph with more than one connected component, the problem of computing φ v (v wconn2 ) reduces Input: Nice tree decomposition (T, {Xt | t ∈ T }) with root node r, such that Xr = {v} Output: Shapley value φv(v conn ) (resp.φv(v wconn2 )). procedure Listing 1: Algorithm for computing the Shapley value -Main Procedure to computing, for each k, the total weight of connected subsets S ⊆ V (G) with |S| = k and v ∈ S (resp.v ∈ S).For v conn , we simply need to count the number of such subsets rather than compute their total weight.
As is standard for algorithms using dynamic programming on tree decompositions, for each node t of the tree decomposition we consider the subgraph G[t].For each such subgraph, we consider the subsets (coalitions) S ⊆ G [t].
Recall that if S ⊆ V (G) is not connected, it (by definition) does not contribute to the Shapley value.Call a subset S ⊆ V (G[t]) good if the subgraph G[S] induced by S is connected or every connected component of G[S] has non-empty intersection with X t .By definition, the empty set is good.
Our algorithm works by, for each t ∈ T , considering all good subsets S ⊆ V (G[t]).The following Lemma shows that subsets that are not good do not count towards the Shapley value of the game, and thus we can safely disregard them.
) has an empty intersection with X t .Then S can not be connected, since by Lemma 1 X t separates G[t] from the rest of the graph.
Of course, there can still be exponentially many good subsets.The key to our algorithm is that for each such subset S, we do not need to know exactly how the subset is made up: if we know how the subset S behaves within X t , we know how it interacts with the rest of the graph (outside of G[t]), since X t is a separator.Subsets which behave similarly within X t can be grouped together, thus speeding up the computation.We classify the subsets into groups depending on their interaction with the rest of the graph.Specifically, each subset For the equivalence relation ∼, note that each element can be in one of at most tw + 1 equivalence classes, a trivial upper bound on the number of such relation is (tw + 1) tw+1 .The number of subsets R is at most 2 tw+1 ; this is dominated by the number of equivalence relations.k can take values in the range 0, . . ., n.Thus, the total number of distinct characteristics is 2 O(tw log tw) n.For every node t ∈ T and each characteristic (R, ∼, k), we will compute n t (R, ∼, k): the number of good subsets S ⊆ G[t] with characteristic (R, ∼ , k), w t (R, ∼, k): the total weight of all good subsets S ⊆ G[t] with characteristic (R, ∼, k).
Note that the weight of a subset S ⊆ G[t] is simply the sum of the vertex weights, i.e. v∈S w(v).
Note that if r is the root of T , and X r = {v}.Then w r ({v}, {v}, k) is exactly the total weight of connected subsets S ⊆ V (G) with |S| = k and v ∈ S, whereas w r (∅, ∅, k) is the total weight of connected subsets of size k not including v.This gives us exactly the information we need to compute φ v (v wconn2 ).
The following example illustrates the characteristics (R, ∼, k).
Example 1 Consider the graph shown in Figure 2a   Input: Leaf node t of a tree decomposition.
For every node t ∈ T we compute n t (R, ∼, k) and w t (R, ∼, k) for each characteristic (R, ∼, k) in a bottom-up fashion.We start at the leaf vertices, and then work our way up the root of the tree.We handle each of the cases as follows: Leaf.If t ∈ T is a leaf node, then X t = {v} for some v ∈ V .Since G[t] is a singleton vertex, t has exactly two characteristics c 1 = (∅, ∅, 0) and c 2 = ({v}, {(v, v)}, 1) (corresponding to the only two subsets S ⊂ G[t], which are the empty set and the singleton {v}).It is easy to see that n t (c 1 ) = 1, w t (c 1 ) = 0 and n t (c 2 ) = 1, w t (c 1 ) = w(v).Pseudocode for the Leaf procedure is given in Listing 2.
Introduce.If t ∈ T is an introduce node, it has a single child t ∈ T and and we may extend these subsets S ⊆ G[t ] to subsets of G[t] by either adding the introduced vertex v or not.Thus, the n t (R, ∼, k) subsets of G[t ] give rise to Input: Introduce node t of a tree decomposition; dynamic programming tables n t and w t for child node t .Output: Dynamic programming tables nt and wt.
procedure Introduce(t, n t , w t ) let v ∈ V (G) be the vertex such that Xt = {v} ∪X t for each (R, ∼, k) in the domain of end if end for return (nt, wt) end procedure Listing 3: Algorithm for computing the Shapley value -Introduce Procedure 1. when not adding v, to n t (R, ∼, k) good subsets of G[t] with characteristic (R, ∼, k) and total weight w t (R, ∼, and 2. when adding v, if k = 0 or R = ∅, to n t (R, ∼, k) good subsets of G[t] with characteristic (R ∪ {v}, ∼ , k + 1) and total weight w t (R, ∼, k) + n t (R, ∼ , k) • w(v), 3. when adding v, if k = 0 and R = ∅, then S ∪ {v} has at least two connected components, (at least) one of which does not intersect X t , so it is not a good subset, where ∼ is the relation obtained as the transitive closure of Note that two distinct characteristics (R, ∼, k) and (R , ∼ , k ) with R = R and k = k (but ∼ =∼ ) may give rise (upon addition of the vertex v) to n t (R, ∼, k) + n t (R , ∼ , k ) subsets with the same characteristic (R ∪ {v}, ∼ , k+1) with total weight . Therefore, we can compute n t (R ∪ {v}, ∼ , k + 1) (and similarly, w t (R ∪ {v}, ∼ , k + 1)), by taking the sum of n Pseudocode for the Introduce procedure that illustrates this summation is given in Listing 3.
The following lemma (c.f.Lemma 2) ensures the correctness of the introduce step: Proof Suppose that S ∩G[t ] is not connected, and some connected component C of S ∩ G[t ] has an empty intersection with X t .Suppose the introduced vertex is v. Then v must be adjacent to some vertex of C, but this is impossible since This ensures that we count each good S ⊆ G[t] at least once.The at most once statement follows from the fact that S ∩ G[t ] corresponds to a unique characteristic w.r.t G[t].
Input: Forget node t of a tree decomposition; dynamic programming n t and w t for child node t .Output: Dynamic programming tables nt and wt. procedure Listing 4: Algorithm for computing the Shapley value -Forget Procedure then there are three cases: 1. R = {v}.Then we obtain n t (R, ∼, k) good subsets of G[t] with characteristic {∅, ∅, k} and total weight w t (R, ∼, k), 2. R = {v} and {(v, v)} ∈∼.Then none of the n t (R, ∼, k) good subsets of G[t ] are good for G[t], since the connected component containing v does not intersect X t , and there is some other connected component that does intersect X t .3. Otherwise, we obtain where ∼ is the relation obtained by projecting the relation As with the introduce procedure, subsets with a given characteristic wrt.Proof If S is not connected, then S has non-empty intersection with X t .Since X t ⊂ X t , S also has non-empty intersection with X t .
If t ∈ T is a join node, then it has two children l, r such that X l = X r = X t .Suppose that (R l , ∼ l , k l ) is a characteristic of l and (R r , ∼ r , k r ) is a characteristic of r and suppose that R l = R r .Then there are n , where ∼ is the transitive closure of ∼ l ∪ ∼ r .Pseudocode for the Join procedure is given in Listing 5.
Similarly to the introduce and forget cases, multiple distinct characteristics for l, r may, when combined, correspond to the same characteristic for t; we should again take the sum over these characteristics.The correctness follows from the following Lemma: Proof By contradiction.We show the case for the left child, the case for the right child is symmetric.
If S ⊆ V (G[l]) then the lemma follows automatically.Therefore, assume there exists ) is not connected and has a connected component C with empty intersection with X l .Since none of the vertices of S ∩ V (G[r]) are incident to C, C is still a maximal connected component of S, but S has at least one other connected component (since S ∩ V (G[l]) is not connected) and so is not connected, and C has empty intersection with X l = X t .
As it is the most complicated procedure, we also give an example illustrating the join procedure.
Example 2 Consider Figure 2 of Example 1.Consider the join node t and its children l, r.There are 13 subsets † (of G[t]) with characteristic ({D, E}, {{D, E}}, 5).This can be seen as follows, there are: Input: Join node t of a tree decomposition; dynamic programming tables n l , nr, w l and wr for child nodes l, r.Output: Dynamic programming tables nt and wt.
procedure Join(t, n l , nr, w l , wr) for each (R, ∼, k) in the domain of n l do for each (R , ∼ , k ) in the domain of nr such that R = R do let be the transitive closure of ∼, ∼ update nt(R, ∼ , k end for end for return (nt, wt) end procedure Listing 5: Algorithm for computing the Shapley value -Join Procedure and we have that 1 By processing the vertices of the tree decomposition in a bottom-up fashion, we can compute the values n r (R, ∼, k) and w r (R, ∼, k) for all characteristics (R, ∼, k) of the root node r.As we have seen before, knowing these values is sufficient to compute the Shapley value of vertex v. Now, we are ready to provide the proof of Theorem 1.
Proof (Proof of Theorem 1) We assume we are given a nice tree decomposition of G (which we may assume has O(n) nodes).For each node, there are 2 O(tw log tw) n characteristics.To compute the values for one characteristic requires considering (in the worst case, which is the join node) 2 O(tw log tw) n 2 pairs of characteristics for the child nodes.For each such pair, we perform a constant number of multiplications of n-bit integers, taking n log n time.The dynamic programming table for one node of the tree decomposition takes up 2 Θ(tw log tw) n 2 space, but at any given time we only need to keep O(log n) of them in memory.
Of course, this only allows us to evaluate the Shapley value for a single vertex v, under the assumption that for the root bag r, X r = {v} (i.e., v is the only vertex in the root bag).To compute the Shapley value for all vertices, we perform the following operations, starting from a nice tree decomposition: -For every join node t, we create a new node t with X t = X t .t is made the parent of t, and the original parent of t becomes the parent of t .In case t was the root, t becomes the root.Note that t is neither a join, introduce, forget, or leaf node, however, the dynamic programming tables for t are simply equal to those for t (we shall from now on, refer to nodes such as t as nochange nodes).-For every vertex v ∈ V (G), we pick a node of the tree decomposition t such that v ∈ V t .We create a copy t of t, which is made the parent of t, and the original parent of t becomes the parent of t .In case t was the root, t becomes the root.Next, we create another copy t of t .t is made the parent of t (making t into a join node).We then create a series of introduce nodes, starting from t , such that eventually we end up with a leaf node u, whose bag contains only v.If we now reroot our tree decomposition so that the root becomes u, thanks to the previous transformation, every join node remains a join node -the roles of introduce, forget and nochange nodes can become interchanged.
The following example illustrates the two operations described above.
Example 3 Figure 3 shows an example of this process.Starting from a nice tree decomposition (Figure 3a) a nochange node is added before the join bag A, B (Figure 3b).To create a leaf bag for vertex B, we pick a bag t containing it (in this example the right child of the join bag), insert a node t which becomes the parent of t, create an additional child (of t ) t (thus making t into a join node), then add a leaf bag u (containing only B) as child of t (making t into a forget node).
This process can be repeated until for each vertex v ∈ V (G) there exists a leaf bag containing it.Note that in the example the tree decomposition is rooted at A, but it can also be viewed as being rooted at u (or any other leaf node); this turns t from a forget node into a nochange node, t remains a join node, while the nochange node A, B (currently a child of the root node A) becomes an introduce node (introducing B to the leaf node containing A).
Thus, we now have a tree decomposition that can be rerooted such that any vertex v becomes the sole vertex in the root bag.However, this only gives a 2 Θ(tw log tw) n 5 log n-time algorithm for computing the Shapley values for all the vertices in a given graph, since this would require running the algorithm separately for each root vertex.However, there is a lot of overlap in these computations, as the dynamic programming tables for each subtree may be computed multiple times.By memoizing a table when it is computed (similar to belief propagation in Bayesian Networks, see e.g.Pearl, 1988), we thus obtain a 2 O(tw log tw) n 4 log n-time algorithm using 2 Θ(tw log tw) n 3 space: Theorem 2 Given a graph G of treewidth at most tw, the Shapley value of all vertices v ∈ V (G) can be computed in time 2 Θ(tw log tw) n 4 log n and space 2 Θ(tw log tw) n 3 .

Computational Experiments
In this section, we experimentally evaluate our algorithm.We test it on several real-world (covert) social networks and also on several (artificial) benchmark graphs.We show that our algorithm can compute the Shapley value for these networks in a reasonable amount of time.
We tested our algorithm using the following covert networks found in the literature: -A network of 69 of individuals involved in 9/11 attacks (9-11), where edges represent some kind of tie (such as cooperating in an attack, financial transactions or having trained together) (Krebs, 2002).-A network of 77 Islamic State members in Europe (ise-extended), where edges represent some kind of tie (such as cooperating in an attack, being related or being present in the same location) (Gutfraind and Genkin, 2017).-A network of 293 drug users (drugnet), where edges represent acquaintanceships (Weeks et al., 2002).-A network of 36 Montreal gangs (montreal), where edges represent ties between gangs (Descormiers and Morselli, 2011).-A network of 67 members of Italian gangs (italian), where an edge represents joint membership of a gang (UCINET, 2018).
We also tested our algorithm on several benchmark graphs from the 2018 PACE challenge (Bonnet and Sikora, 2019).These graphs are not social net-works but are intended to demonstrate the capabilities of our algorithms on graphs with a range of treewidth values and vertex counts.
For each network, we considered the largest connected component.Each of these networks has relatively low treewidth.The Islamic State network has the highest treewidth (13), while the Italian Gang network is very sparse (treewidth 3).We also considered using the Noordins top terrorist network (Everton, 2012).However, as this 79-vertex network has treewidth at least 19, applying our techniques is not feasible.
Our implementation simultaneously computes the value of both v conn and v wconn2 (we set all weights to 1 for these experiments, resulting in a game where the value of a connected coalition is equal to its size).
Table 1 reports computational performance results on these benchmark graphs.Our implementation uses the .NET BigInteger library, which performs multiplications in Θ(n 2 ) time using a method similar to grid multiplication.While there are several asymptotically faster methods for multiplication, and we experimented with several such implementations, none of these resulted in a significant speed up for the graphs considered.The time reported is that for computing the Shapley values of all vertices in the graph, using the method that stores all intermediate tables to achieve a 2 O(tw log tw) n 4 log n computation time.The time reported does not include the time for computing a tree decomposition, however there are many algorithms that can quickly compute a tree decomposition for many graphs of practical interest (see e.g., Tamaki, 2019).
We are able to compute the Shapley value for each of the covert networks in less than two minutes.For the 9/11 network, our computation took only 5.3 seconds.The Shapley value for this network has previously been approximated by van Campen et al. (2017), using a method based on a random sampling of 10.000 permutations of the players in the network.Lindelauf et al. report that this computation of approximate Shapley values took 5 minutes.Our method is not only exact, but also much faster.
Of course, the method of van Campen et al. ( 2017) can be applied to any graph rather than just to graphs of small treewidth.However, it is not yet known how the performance of their approximation depends on the structure of the graph.Still, when the treewidth of the graph is small, our method provides an excellent way to compute exact Shapley values.
The IS in Europe network has treewidth 13.Despite this relatively high treewidth, our algorithm was still able to compute the Shapley value in 38.7 seconds.Our algorithm can thus handle graphs even with moderate treewidth quite quickly.It can also handle graphs with large numbers of vertices, although it appears from the results on the PACE networks that the polynomial factor in the running time (n 4 ) starts to dominate rather than the dependence on the treewidth.

Conclusions
Game-theoretic centrality measures are a powerful tool for identifying important vertices in networks.We have shown that, using treewidth, two gametheoretic centrality measures can be practically computed on graphs much larger than previously feasible, allowing us to analyze larger networks than before.
Our algorithm runs in time 2 O(tw log tw) n O(1) .The log-factor in the exponent is due to the need to keep track of a connectivity partition.A very interesting open question is whether the algorithm can be improved to have single-exponential running time, that is, is it possible to attain a 2 O(tw) n O(1)time algorithm?For several (counting) problems involving connectivity, this is indeed possible: For instance, it is possible to count Hamiltonian Cycles or Steiner Trees in single-exponential time (Bodlaender et al., 2015) by using approaches involving matrix determinants.Either a positive answer to this question or a conditional lower bound ruling out such an algorithm would be interesting.
We remark that the log-factor in the exponent represents only the worst case.However, since we are dealing with induced subgraphs, if two vertices share an edge, they can never be in two distinct connected components.Therefore, the actual number of connectivity partitions considered may be lower than suggested by the worst case bound.It would be interesting to see if it is possible to take this phenomenon into account when generating a tree decomposition: perhaps it would be possible to optimize a tree decomposition to limit the number of feasible partitions (for instance, by giving preference to bags that are cliques).Such an approach has previously been considered for Steiner Tree (van der Graaff, 2015).
With a trivial adaptation, our algorithm can also be used to compute the Banzhaf value (Banzhaf, 1964) for v conn and v wconn2 ; this requires merely a change in weighting values.Techniques similar to ours can also be used to evaluate other connectivity games, e.g., the Shapley value for v wconn1 and v wconn3 (Lindelauf et al., 2013) can be computed by extending our notion of characteristic to also include the maximum weight of an edge in the subgraph induced by S.
Another interesting question is whether other connectivity measures can be computed using treewidth.For instance, v conn assigns a value of 0 to any disconnected coalition, even if there exists a large connected component.It might be more reasonable to make the value of a coalition equal to the size of the largest connected component inside this coalition.It is easy to adapt our techniques to obtain an algorithm running in time n O(tw) for this case; it would be interesting to see if a fixed-parameter tractable algorithm exists.
that a ∼ b if and only if a and b are in the same connected component of the subgraph induced by S, the cardinality of S, k = |S|.
and the tree decomposition shown in Figure 2b.The induced subgraph G[r] associated with node r consists of vertices D, E, F, G, H, I.The subset {G, D} is not good because the connected component {G} has an empty intersection with X r = {D, E, F }.The subset {D, E, G, H} is good, and has characteristic

Fig. 2 :
Fig. 2: (a) Example of a 9-vertex graph.(b) Tree decomposition for the graph in (a); note that the decomposition given is neither of optimal width nor nice.
Fig. 3: (a) A (nice) tree decomposition.(b) A nochange node is added before the join bag A, B. (c) Extra nodes t and t are added to enable the creation of a leaf bag containing vertex B, which can be used to re-root the decomposition.
ComputeShapley(T, r) let r be the root of T for each node t ∈ T in post-order do if t is a leaf node then let (wt, nt) = Leaf(t) end if if t is an introduce node then let t be the child of t let n t , w t be the previously computed tables for t let (wt, nt) = Introduce(t, n t , w t ) end if if t is a forget node then let t be the child of t let n t , w t be the previously computed tables for t let (wt, nt) = Forget(t, n t , w t ) end if if t is an join node then let l, r be the children of t let n l , nr, w l , wr be the previously computed tables for l, r let (wt, nt) = Join(t, n l , nr, w l , wr) G[t] may correspond to subsets with different characteristics for G[t ], so to compute the table entries wrt.G[t] we must once again take the sum of relevant table entries wrt.G[t ].Pseudocode for the Forget procedure is given in Listing 4. The correctness follows from the following Lemma: Lemma 4 Let t ∈ T and suppose that t is a forget vertex with child t ∈ T .Suppose S ⊆ G[t] is a good subset.Then S is a good subset of G[t ].

Table 1 :
Performance of the algorithm on several real-world networks and several benchmark graphs from the PACE 2018 challenge.For disconnected graphs, we considered only the largest connected component in the graph (for which the number of vertices and edges is given).