2012 ACM Subject Classification Theory of computation → Design and analysis of algorithms
Usage of AI We used the free version of LLMs for two purposes. First, to find related work we might have missed and for minor uses (proofreading, LaTeX help, TikZ, etc.). Second, the proof of the W[1 ] -hardness result (Theorem 5.2) was found with LLM assistance.
Introduction
Probabilistic graphs have been studied in computer science both as a theoretical object of study and as an applicative model [32 ] , e.g., describing possible failures in a computer network, closures on road networks, uncertain connections in social networks, etc. We consider the simplest such model: every edge is annotated with a probability, and the edge is then present with this probability, independently from all other edges. Such graphs are an arity-two case of tuple-independent probabilistic databases [34 ] , which have also been studied in their own right [7 , 29 , 4 ] .
We study the question of efficiently finding paths in such graphs, which is related to the two-terminal network reliability problem in probabilistic graphs (ST-CON). This problem asks, given a probabilistic graph G \mathcal{G} G , a source s s s , and a target t t t , what is the probability that there is some path from s s s to t t t , i.e., what is the total probability of the graphs having such a path in the distribution represented by the graph G \mathcal{G} G . We can of course always solve this problem exactly by considering every possible realisation of G \mathcal{G} G , solving the (non-probabilistic) s t st s t -reachability problem, and summing the probabilities of the realisations where a path exists. However, in general the number of realisations is exponential in the size of G \mathcal{G} G , so this algorithm is inefficient. It has in fact been shown [35 Theorem 1] that ST-CON is # P \#P # P -complete, so it is unlikely that substantially better algorithms exist.
However, the tractability of ST-CON is regained when the probabilistic graph is assumed to have bounded treewidth [9 , 37 , 25 ] , i.e., to be similar to a tree. More precisely, for any treewidth bound k ∈ N k \in\mathbb{N} k ∈ N , the ST-CON problem can be solved in polynomial time when the input probabilistic graphs are restricted to have treewidth at most k k k ; in fact the problem is fixed-parameter tractable (FPT) when parameterised by treewidth. This observation generalises to the fixed-parameter tractability of the class of monadic second-order queries (MSO) on tuple-independent probabilistic databases parameterized by treewidth, namely, the problem is in linear time in the database up to the cost of arithmetic operations [2 , 3 ] . While the motivation of treewidth is theoretical, its amenability to dynamic programming techniques makes it potentially attractive for practical applications, and the experimental treewidth of practical data has for instance been investigated in earlier work [30 ] .
However, these results do not address the task of finding paths of specified lengths in probabilistic graphs, a query which is not generally expressible in MSO. For instance, we can ask for the probability that the shortest path from s s s to t t t has length less than some threshold, e.g., to check if t t t can be reached from s s s in a road network with edge probabilities subject to a time budget. Such questions have been investigated [32 , 38 ] , in particular in connection to the computation of most probable shortest paths that form a kind of generalisation of shortest paths in probabilistic graphs. However, while these tasks are generally intractable on unrestricted probabilistic graphs, to our knowledge it had not been investigated whether tractability could also be regained in this setting by bounding the treewidth, ideally with an FPT algorithm. The one exception we are aware of is the very recent preprint of Ando [8 ] , which gives a # P \#P # P -hardness proof and an XP algorithm parameterised by treewidth to compute the distribution of the longest and shortest simple paths in a probabilistic graph. However their setting is different because they consider edge lengths that are probabilistic (according to a continuous distribution), whereas we consider graphs with edges annotated by a probability of existence. It turns out however that some aspects of the # P \#P # P -hardness proof of [8 ] are related to the W[1 ] -hardness proof that we present later.
Contributions. In this paper, we consider the question of computing paths satisfying length constraints in probabilistic graphs. More precisely, we consider three types of length requirements: asking for paths of length ≤ ℓ \le\ell ≤ ℓ , or = ℓ = \ell = ℓ , or ≥ ℓ \ge\ell ≥ ℓ , for an integer threshold ℓ \ell ℓ given as input (and written in binary). We consider the search for simple paths, and the search for walks (which may revisit a given vertex): while this choice makes no difference for shortest paths (or paths of length ≤ ℓ \le\ell ≤ ℓ ), it may make a difference in general because revisiting vertices may be useful to achieve higher lengths. This gives six problem combinations: P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\le} PLEP ≤ Path , P L E P = P a t h \mathrm{PLEP}^{\mathrm{Path}}_{=} PLEP = Path , and P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\ge} PLEP ≥ Path for paths; and P L E P ≤ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\le} PLEP ≤ Walk , P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk , and P L E P ≥ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\ge} PLEP ≥ Walk for walks.
For each of these six problems, the input consists of a probabilistic graph G \mathcal{G} G , a source vertex s s s and target vertex t t t , and the threshold ℓ \ell ℓ . Our task is to compute the total probability of the realisations of G \mathcal{G} G where a suitable path from s s s to t t t exists. Our goal is to study the complexity of these problems when the input graph G \mathcal{G} G has bounded treewidth.
To our surprise, the complexity landscape turns out to be more complicated than expected. We initially expected these problems to behave like ST-CON, and to be fixed-parameter tractable on bounded-treewidth data by being captured by a suitable logic (e.g., an extension of monadic second-order logic, in the spirit of quantitative MSO [28 , 27 ] or other extensions [27 ] ). However, it turns out that tractability does not always hold, that they generally do not enjoy FPT algorithms (conditionally), and that in particular the six problems do not have the same complexity. We now present the results that we obtain, and the structure of the paper.
After formally defining our problems in Section 2, we first review the complexity of the six problems on non-probabilistic graphs in Section 3. Indeed, the problems P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\le} PLEP ≤ Path and P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\ge} PLEP ≥ Path , which ask for long simple paths, are NP-hard already on non-probabilistic graphs because of an immediate reduction from the Hamiltonian path problem. So we introduce treewidth as a way to regain tractability, and show that all six variants of our problems are FPT when parameterised by treewidth. This result is not surprising and follows known constructions, e.g., for the Hamiltonian path problem on bounded-treewidth graphs [39 ] , for which efficient FPT algorithms are known [17 , 19 , 20 ] achieving c O ( k ) n O ( 1 ) c^{O(k)}n^{O(1)} c O ( k ) n O ( 1 ) for some constant c c c and with k k k the input treewidth. We will sketch in the section a self-contained proof of these results, introducing notions that will be lifted later to study P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\ge} PLEP ≥ Path on bounded-treewidth probabilistic graphs. The situation for non-probabilistic graphs is summarised in Table 1a.
We then move to probabilistic graphs in Section 4. Like ST-CON, all six problems become # \# # -hard when the input probabilistic graphs are arbitrary; so we study the impact of bounding the treewidth. We show that, for treewidth-1 graphs (i.e., probabilistic forests), the six problems indeed become tractable, by an ad-hoc dynamic programming argument.
The key technical results of the paper are given in Section 5, where we investigate whether tractability extends to arbitrary treewidth bounds. We show tractability on bounded-treewidth probabilistic graphs of four of our six problems: P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\le} PLEP ≤ Path , P L E P ≤ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\le} PLEP ≤ Walk , P L E P ≥ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\ge} PLEP ≥ Walk , and P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\ge} PLEP ≥ Path . Namely, we show that these algorithms are XP parameterised by treewidth, and that they are likely not FPT because they are W[1 ] -hard already on acyclic graphs and when parameterising by pathwidth. Note that this contrasts both with the FPT results for these problems on non-probabilistic graphs, and with the FPT results for ST-CON on probabilistic graphs. Our XP algorithms are shown by standard dynamic programming arguments but with significant complications to account for the probabilistic computations: we first cover the problems P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\ge} PLEP ≥ Path and P L E P ≤ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\le} PLEP ≤ Walk , then the problem P L E P ≥ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\ge} PLEP ≥ Walk which adds the computation of handling “arbitrarily high” walk lengths, then the problem P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\ge} PLEP ≥ Path which asks for long simple paths. This latter problem is the most complicated one to cover, as we must both perform probability computations and ensure that the witnessing paths are simple, generalising the technique used on non-probabilistic graphs. In all these results, we use the “monotonicity” of the ≤ ℓ \le\ell ≤ ℓ and ≥ ℓ \ge\ell ≥ ℓ requirements: they intuitively make it possible to concisely summarise realisations in a bottom-up dynamic programming algorithm on the tree decomposition, by considering the best possible choices of paths that can be achieved below each bag and using this as a way to group realisations together. The W[1 ] -hardness proof is by a reduction from the problem of counting the number of linear extensions of a partially ordered set, like in [8 ] .
The natural question is whether we can similarly design tractable algorithms for P L E P ≡ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\equiv} PLEP ≡ Path and P L E P ≡ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\equiv} PLEP ≡ Walk on bounded-treewidth probabilistic graphs. Surprisingly, we show in Section 6 that the answer is negative (under standard complexity assumptions). Namely, we show that the two problems P L E P ≡ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\equiv} PLEP ≡ Path and P L E P ≡ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\equiv} PLEP ≡ Walk are # \# # -hard already on pathwidth-2 probabilistic graphs. Note that, because we are talking about the probability of existence of paths of a certain length, the probability of existence of a path of length exactly ℓ \ell ℓ cannot be obtained simply by subtracting, e.g., the probability of existence of paths of length ≤ ℓ − 1 \le\ell- 1 ≤ ℓ − 1 from the probability of existence of paths of length ≤ ℓ \le\ell ≤ ℓ (as the corresponding outcomes are not mutually exclusive). The situation is summarised in Table 1b.
We then study in Section 7 the variants of our problems on weighted graphs , i.e., the edges of the graph carry weights (written in binary) in addition to their probabilities, and the length requirements now pertain to the total weights of paths. The use of weights can be relevant, e.g., to model lengths or durations in routing applications. We show that adding weights can have a significant impact on the complexity of our problems: it makes P L E P ≤ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\leq} PLEP ≤ Walk and P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\leq} PLEP ≤ Path NP-hard already on pathwidth-2 non-probabilistic graphs, and in the presence of both probabilities and weights all our problem variants become #P-hard on pathwidth-2 graphs. We also show #P-hardness on pathwidth-1 graphs for P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk specifically when we have weights and probabilities, remembering that the problem P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk was tractable on treewidth-1 unweighted probabilistic graphs.
Table 1. Summary of the complexity of the problems P L E P ⋈ X \mathrm{PLEP}^{X}_{\bowtie} PLEP ⋈ X .
We conclude in Section 8. Most detailed proofs are deferred to the appendix.
Preliminaries and Problem Statement
Graphs, walks, (simple) paths. A (directed) graph G = ( V , E ) G=(V,E) G = ( V , E ) consists of a finite set V V V of vertices and of a set E ⊆ V × V E\subseteq V\times V E ⊆ V × V of edges. For E ′ ⊆ E E'\subseteq E E ′ ⊆ E , we write G [ E ′ ] G[E'] G [ E ′ ] the subgraph defined by G [ E ′ ] = ( V , E ′ ) G[E']=(V,E') G [ E ′ ] = ( V , E ′ ) . A walk w w w in G G G is a non-empty sequence of vertices w = v 1 , … , v n w=v_1,\ldots,v_n w = v 1 , … , v n of V V V such that ( v i , v i + 1 ) ∈ E (v_i,v_{i+1})\in E ( v i , v i + 1 ) ∈ E for 1 ≤ i ≤ n − 1 1\leq i\leq n-1 1 ≤ i ≤ n − 1 , and its length, denoted ∣ w ∣ |w| ∣ w ∣ , is n − 1 n-1 n − 1 . A simple path, or simply path, is a walk in which all vertices are distinct. The endpoints of a walk are the first and last vertices, and its internal vertices are all other vertices. For G G G a graph, we sometimes write V ( G ) V(G) V ( G ) for its set of vertices and E ( G ) E(G) E ( G ) for its set of edges.
Path length problems over non-probabilistic graphs. The problems studied in this paper deal with the existence of walks or paths from one vertex to another in graphs, where the walks/paths satisfy a length constraint. We focus on the following constraints: the walk/path must have length at most, exactly, or at least ℓ \ell ℓ , where ℓ \ell ℓ is an integer given as input in binary. This gives rise to 6 computational problems, which we denote P L E P ⋈ X \mathrm{PLEP}^{X}_{\bowtie} PLEP ⋈ X for ⋈ ∈ { ≤ , = , ≥ } \bowtie\in\{\leq,=,\geq\} ⋈∈ { ≤ , = , ≥ } and X ∈ { W a l k , P a t h } X\in\{\mathrm{Walk},\mathrm{Path}\} X ∈ { Walk , Path } , defined as follows (“PLEP” stands for Path Length Existence Problem ):
For instance, the problem P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\leq} PLEP ≤ Path asks whether there is a path from s s s to t t t of length at most ℓ \ell ℓ . Equivalently, it asks whether the length of a shortest path from s s s to t t t is at most ℓ \ell ℓ . Further note that P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\leq} PLEP ≤ Path and P L E P ≤ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\leq} PLEP ≤ Walk are identical, because shortest walks are always paths; but the same is not true of P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\geq} PLEP ≥ Path and P L E P ≥ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\geq} PLEP ≥ Walk , or of P L E P = P a t h \mathrm{PLEP}^{\mathrm{Path}}_{=} PLEP = Path and P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk .
Before moving on to the probabilistic setting, we recall known results on the complexity of these (rather standard) problems in the non-probabilistic setting (see Table 1a). Problem P L E P ≤ W a l k = P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Walk}}_{\leq}=\mathrm{PLEP}^{\mathrm{Path}}_{\leq} PLEP ≤ Walk = PLEP ≤ Path simply amounts to computing the length of a shortest path from s s s to t t t , which is PTIME. Problems P L E P = P a t h \mathrm{PLEP}^{\mathrm{Path}}_{=} PLEP = Path and P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\geq} PLEP ≥ Path are (obviously in NP and) NP-hard by reduction from Hamiltonian path with prescribed endpoints (even when the target length is given in unary). The problem P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk is PTIME, using fast exponentiation of the graph’s adjacency matrix. The problem P L E P ≥ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\geq} PLEP ≥ Walk is PTIME too, by creating ℓ \ell ℓ copies of the graph and performing a reachability test (assuming without loss of generality that ℓ \ell ℓ is at most ∣ V ∣ |V| ∣ V ∣ ).
Probabilistic graphs. A probabilistic graph is a triple G = ( V , E , π ) \mathcal{G}=(V,E,\pi) G = ( V , E , π ) , where G = ( V , E ) G=(V,E) G = ( V , E ) is a graph, called the underlying non-probabilistic graph , and π : E → [ 0 , 1 ] \pi:E\to[0,1] π : E → [ 0 , 1 ] assigns a probability value to every edge. A realisation of G \mathcal{G} G is a graph of the form G [ E ′ ] G[E'] G [ E ′ ] for E ′ ⊆ E E'\subseteq E E ′ ⊆ E . The probabilistic graph G \mathcal{G} G defines a probability distribution on the set of its realisations, by keeping or discarding each edge e ∈ E e\in E e ∈ E with probability π ( e ) \pi(e) π ( e ) , independently across edges. Formally, for a given realisation G [ E ′ ] G[E'] G [ E ′ ] of G \mathcal{G} G , its probability, denoted Pr G ( E ′ ) \Pr_{\mathcal{G}}(E') Pr G ( E ′ ) , is the quantity
Pr G ( E ′ ) = ∏ e ∈ E ′ π ( e ) ⋅ ∏ e ∈ E ∖ E ′ ( 1 − π ( e ) ) . \Pr_{\mathcal{G}}(E')=\prod_{e\in E'}\pi(e)\cdot\prod_{e\in E\setminus E'}(1-\pi(e)). G Pr ( E ′ ) = e ∈ E ′ ∏ π ( e ) ⋅ e ∈ E ∖ E ′ ∏ ( 1 − π ( e )) .
Note that realisations may have probability 0 0 0 .
Problem statement. We extend the PLEP problems to probabilistic graphs in the natural way by asking for the probability that the input graph satisfies the required conditions. More precisely, for □ ∈ { ≤ , = , ≥ } \square\in\{\leq,=,\geq\} □ ∈ { ≤ , = , ≥ } and for X ∈ { W a l k , P a t h } X\in\{\mathrm{Walk},\mathrm{Path}\} X ∈ { Walk , Path } , the P L E P □ X \mathrm{PLEP}^{X}_{\square} PLEP □ X problem is as follows. We receive as input a probabilistic graph G = ( V , E , π ) \mathcal{G}=(V,E,\pi) G = ( V , E , π ) , vertices s s s and t t t , and an integer ℓ ≥ 0 \ell\geq0 ℓ ≥ 0 written in binary. Our task is to compute the sum over all E ′ ⊆ E E'\subseteq E E ′ ⊆ E of the probabilities Pr G ( E ′ ) \Pr_{\mathcal{G}}(E') Pr G ( E ′ ) of the realisations of G \mathcal{G} G that satisfy P L E P □ X \mathrm{PLEP}^{X}_{\square} PLEP □ X for s s s , t t t , and ℓ \ell ℓ . Notice that the non-probabilistic setting is a special case of the probabilistic setting in which all edges have probability 1 1 1 .
Computational model. Recall that #P is the class of counting problems that can be expressed as counting the number of accepting paths of a nondeterministic polynomial-time Turing machine. Following Valiant [36 , 35 ] , we define #P-hardness using Turing reductions (i.e., with oracles). In all our problems, unless stated otherwise, probability values are given as rational numbers p q \frac{p}{q} q p with ( p , q ) ∈ N × ( N ∖ { 0 } ) (p,q)\in\mathbb{N}\times(\mathbb{N}\setminus\{0\}) ( p , q ) ∈ N × ( N ∖ { 0 }) , where p p p and q q q are encoded in binary. All probability computation problems that we study are in F P # P \mathrm{FP}^{\#\mathrm{P}} FP # P , i.e., they can be solved in polynomial time with access to a #P oracle.
Treewidth
We have seen that already in the non-probabilistic setting, the PLEP problems may be intractable: this is specifically the case of P L E P = P a t h \mathrm{PLEP}^{\mathrm{Path}}_{=} PLEP = Path and P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\geq} PLEP ≥ Path . One common way to regain tractability of problems on graphs is to bound their treewidth . In this section, we recall the definition of treewidth, defining tree decompositions and mentioning the nice tree decompositions that we will use in our proofs. We then review the folklore result that all PLEP problems are tractable on non-probabilistic graphs when the input is assumed to have bounded treewidth. This only needs to be explained for P L E P = P a t h \mathrm{PLEP}^{\mathrm{Path}}_{=} PLEP = Path and P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\geq} PLEP ≥ Path since the other problems are tractable on arbitrary graphs. Namely, we will review the following result:
Theorem 3.1 (Folklore). For non-probabilistic graphs, the problems P L E P = P a t h \mathrm{PLEP}^{\mathrm{Path}}_{=} PLEP = Path and P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\geq} PLEP ≥ Path are FPT parameterised by treewidth.
Once this is done, our goal in the rest of the paper will be to study whether this tractability result extends to the probabilistic setting.
Treewidth and nice tree decompositions. A tree decomposition of a graph G = ( V , E ) G=(V,E) G = ( V , E ) is a pair S = ( S , { S b } b ∈ V ( S ) ) \mathcal{S}=(S,\{S_b\}_{b\in V(S)}) S = ( S , { S b } b ∈ V ( S ) ) where S S S is a rooted, unordered tree and where every node b b b is assigned a vertex subset S b ⊆ V ( G ) S_b\subseteq V(G) S b ⊆ V ( G ) , called a bag , such that the following three conditions hold: (i) ⋃ b ∈ V ( S ) S b = V ( G ) \bigcup_{b\in V(S)} S_b=V(G) ⋃ b ∈ V ( S ) S b = V ( G ) , in other words, every vertex of G G G is in at least one bag; (ii) For every ( u , v ) ∈ E (u,v)\in E ( u , v ) ∈ E , there exists a node b b b of S S S such that the bag S b S_b S b contains both u u u and v v v ; (iii) For every u ∈ V u\in V u ∈ V , the set T u = { b ∈ V ( S ) : u ∈ S b } T_u=\{b\in V(S):u\in S_b\} T u = { b ∈ V ( S ) : u ∈ S b } induces a connected subtree of S S S . The width of S = ( S , { S b } b ∈ V ( S ) ) \mathcal{S}=(S,\{S_b\}_{b\in V(S)}) S = ( S , { S b } b ∈ V ( S ) ) is max b ∈ V ( S ) ∣ S b ∣ − 1 \max_{b\in V(S)}|S_b|-1 max b ∈ V ( S ) ∣ S b ∣ − 1 , that is, the maximum size of its bags minus 1. The treewidth of a graph G G G , denoted by tw ( G ) \operatorname{tw}(G) tw ( G ) , is the minimum possible width of a tree decomposition of G G G . Likewise, we define the treewidth of a probabilistic graph G G G to mean the treewidth of its underlying non-probabilistic graph.
We will also use path decompositions and pathwidth in some hardness results. A path decomposition is a tree decomposition whose tree is a (rooted) path, and the pathwidth of a graph G G G (resp., a probabilistic graph G G G ) is the minimum possible width of a path decomposition of G G G (resp., of the underlying non-probabilistic graph of G G G ). We will only use pathwidth to show hardness results (when parameterising by it, or on pathwidth-1 or pathwidth-2 graphs), which allows for crisper results than the corresponding results for treewidth given that pathwidth is always no smaller than treewidth.
By contrast, all our tractability proofs will use treewidth, and for them it will be convenient to use so-called nice tree decompositions [18 ] , which satisfy some additional properties. Specifically, every edge of E E E is introduced in exactly one bag of the decomposition. Further, beyond introduction nodes (which introduce a vertex or an edge), forget nodes (that remove a vertex), and leaf nodes, other nodes b b b have exactly two children, the bags of b b b and its children are identical, and b b b does not introduce any edge (we call such a node a join node ). We define these more formally in Appendix A (but the precise definition should not be needed to understand the main text of our article).
On such tree decompositions, we will use some additional notation. Given a graph G = ( V , E ) G=(V,E) G = ( V , E ) and a nice tree decomposition S = ( S , { S b } b ∈ V ( S ) ) \mathcal{S}=(S,\{S_b\}_{b\in V(S)}) S = ( S , { S b } b ∈ V ( S ) ) of G G G , for b b b a node in the tree S S S , we define V b V_b V b as the set of vertices included in any of the bags contained in the subtree rooted at b b b . We further define G b G_b G b as the graph whose vertices are V b V_b V b and whose edges are exactly those that are introduced in some bag of the subtree rooted at b b b . In particular, if b b b is a join node with children b 1 , b 2 b_1,b_2 b 1 , b 2 , then G b G_b G b is the disjoint union (in terms of edges) of G b 1 G_{b_1} G b 1 and G b 2 G_{b_2} G b 2 .
It follows from standard techniques [16 , 18 ] that we can compute nice tree decompositions in FPT-linear time and further ensure that the root bag precisely contains the source and target vertices. Formally, we will always use the following implicitly in our proofs:
Lemma 3.2 ([16 ] ). There is an algorithm and a polynomial p p p which, given as input a graph G = ( V , E ) G=(V,E) G = ( V , E ) with two distinguished vertices s , t ∈ V s,t\in V s , t ∈ V and an integer k k k , determines if tw ( G ) ≤ k \operatorname{tw}(G)\le k tw ( G ) ≤ k , and if yes, computes a nice tree decomposition of G G G of width at most tw ( G ) + 1 \operatorname{tw}(G)+1 tw ( G ) + 1 whose root bag is { s , t } \{s,t\} { s , t } , in time O ( 2 p ( k ) ∣ V ∣ ) O(2^{p(k)}|V|) O ( 2 p ( k ) ∣ V ∣ ) .
Sketching the proof of Theorem 3.1 . We now review the high-level ideas to prove Theorem 3.1 , as some of our later results will generalise these techniques. We first notice that the problem P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\ge} PLEP ≥ Path reduces to P L E P P a t h \mathrm{PLEP}^{\mathrm{Path}} PLEP Path in polynomial time (using the fact that a simple path cannot be longer than ∣ V ( G ) ∣ |V(G)| ∣ V ( G ) ∣ ). Hence, we only need to show that P L E P P a t h \mathrm{PLEP}^{\mathrm{Path}} PLEP Path is FPT parameterised by treewidth.
To do this, we adapt the so-called naïve approach described in [39 Section 2.2] that is used to find Hamiltonian paths. While this seems to be folklore, we could not find a reference that explains how to do this for simple paths with a length constraint and specified endpoints. The closest we found is [17 Theorem 3.20] , but there the endpoints are not specified and the techniques used are much more evolved (i.e., this is not the “naïve approach”). At a high level, the idea is to solve the problem by dynamic programming, processing the tree decomposition bottom-up to determine, for each bag b b b , what are the “partial solutions” of the problem in the subgraph G b G_b G b . We need a few definitions to precisely explain what partial solutions are, which we sketch here and will formally redefine and extend for algorithms on probabilistic graphs later. In these definitions, the set of vertices A A A will intuitively be a bag of the tree decomposition.
Definition 3.3. For G = ( V , E ) G=(V,E) G = ( V , E ) a graph and P \mathcal{P} P a set of paths in G G G , we call P \mathcal{P} P vertex-disjoint if for any two distinct paths P 1 , P 2 ∈ P P_1,P_2\in\mathcal{P} P 1 , P 2 ∈ P , no vertex of P 1 P_1 P 1 occurs in P 2 P_2 P 2 . The length of P \mathcal{P} P , denoted length ( P ) \operatorname{length}(\mathcal{P}) length ( P ) , is then the sum of lengths of the paths that P \mathcal{P} P contains. For A ⊆ V A\subseteq V A ⊆ V , a set of paths P \mathcal{P} P is A A A -vertex-disjoint if it is vertex-disjoint, and for each path P ∈ P P\in\mathcal{P} P ∈ P , the endpoints of P P P are vertices in A A A .
Definition 3.4. Let G = ( V , E ) G=(V,E) G = ( V , E ) be a graph, A ⊆ V A\subseteq V A ⊆ V a set of vertices of G G G , and P \mathcal{P} P a path in G G G whose endpoints are vertices of A A A . We define the projection of P P P relative to G G G and A A A , written Proj G , A ( P ) \operatorname{Proj}_{G,A}(P) Proj G , A ( P ) , to be the tuple comprising those vertices of P P P that are in A A A , in the order in which they occur in P P P .
Note that the tuple has at least one element, as it contains at least the endpoints of the path (and there is only one endpoint in case ∣ P ∣ = 0 |P| = 0 ∣ P ∣ = 0 , i.e., P P P is a single-vertex path), but it may have more if some internal vertices of P P P are in A A A .
We extend this notion to define the projection of an A A A -vertex-disjoint set of paths P \mathcal{P} P of G G G as Proj G , A ( P ) = { Proj G , A ( P ) ∣ P ∈ P } \operatorname{Proj}_{G,A}(\mathcal{P}) = \{\operatorname{Proj}_{G,A}(P) \mid P \in\mathcal{P}\} Proj G , A ( P ) = { Proj G , A ( P ) ∣ P ∈ P } ; we call such a set a path set projection. Finally, we define the disjoint path set projection of A A A relative to G G G , denoted by PSP G ( A ) \operatorname{PSP}_{G}(A) PSP G ( A ) , to be the set of the path set projections of all A A A -vertex-disjoint sets of paths of G G G , formally, PSP G ( A ) : = { Proj G , A ( P ) ∣ P is an A -vertex-disjoint set of paths of G } \operatorname{PSP}_{G}(A) := \{\operatorname{Proj}_{G,A}(\mathcal{P}) \mid\mathcal{P}\text{ is an }A\text{-vertex-disjoint set of paths of }G\} PSP G ( A ) := { Proj G , A ( P ) ∣ P is an A -vertex-disjoint set of paths of G } .
The algorithm that we propose to solve P L E P P a t h \mathrm{PLEP}^{\mathrm{Path}} PLEP Path over non-probabilistic bounded-treewidth graphs is then as follows. We process the tree decomposition bottom-up and, for every node b b b of the decomposition, we compute the following information: (1.) the set PSP G b ( S b ) \operatorname{PSP}_{G_b}(S_b) PSP G b ( S b ) , and (2.) for every path set projection Π ∈ PSP G b ( S b ) \Pi\in\operatorname{PSP}_{G_b}(S_b) Π ∈ PSP G b ( S b ) , the set of natural numbers
{ length ( P ) ∣ P is an S b -vertex-disjoint set of paths of G b such that Proj G b , S b ( P ) = Π } . \{\operatorname{length}(\mathcal{P}) \mid\mathcal{P}\text{ is an }S_b\text{-vertex-disjoint set of paths of }G_b\text{ such that }\operatorname{Proj}_{G_b,S_b}(\mathcal{P}) = \Pi\}. { length ( P ) ∣ P is an S b -vertex-disjoint set of paths of G b such that Proj G b , S b ( P ) = Π } .
We briefly sketch how this information can be computed bottom-up. If b b b is a leaf node the computation is easy, and if b b b is a join node we can compute the information from the two children b 1 , b 2 b_1,b_2 b 1 , b 2 of b b b . This is because, by the properties of nice tree decompositions, when P \mathcal{P} P is an S b S_b S b -vertex-disjoint set of paths of G b G_b G b , P \mathcal{P} P can be decomposed as a concatenation of some S b 1 S_{b_1} S b 1 -vertex-disjoint sets of paths P 1 \mathcal{P}_1 P 1 of G b 1 G_{b_1} G b 1 and some S b 2 S_{b_2} S b 2 -vertex-disjoint sets of paths P 2 \mathcal{P}_2 P 2 of G b 2 G_{b_2} G b 2 . Furthermore, since PSP G b ( S b ) \operatorname{PSP}_{G_b}(S_b) PSP G b ( S b ) is a set of sets of tuples of vertices of S b S_b S b , its size depends only on k k k , so the total size of the information that we compute for every node b b b of the tree decomposition is bounded1 by n × f ( k ) n \times f(k) n × f ( k ) . When we reach the root bag b r o o t b_{\mathrm{root}} b root , with S b r o o t = { s , t } S_{b_{\mathrm{root}}} = \{s,t\} S b root = { s , t } and G b r o o t = G G_{b_{\mathrm{root}}} = G G b root = G , we have the information we need to decide if there exists a simple path of length ℓ \ell ℓ in G G G from s s s to t t t , namely, consider the path set projection P = { ( s , t ) } \mathcal{P} = \{(s,t)\} P = {( s , t )} (or { ( s ) } \{(s)\} {( s )} if s = t s=t s = t ) and see whether the length ℓ \ell ℓ was achieved for P \mathcal{P} P . All in all, this gives us an algorithm with complexity f ( k ) × n O ( 1 ) f(k) \times n^{O(1)} f ( k ) × n O ( 1 ) , i.e., FPT parameterised by treewidth, as promised.
Introducing Probabilities
We now move to the study of the PLEP problems on probabilistic graphs, presenting in this section their complexity in two extreme regimes.
First, we show that the PLEP problems are all intractable on probabilistic graphs of unbounded treewidth: this simply follows from the fact that source-to-target reachability (ST-CON) is # \# # P-hard [35 ] , and we recall a standard self-contained reduction from the # \# # PP2DNF problem for the reader’s convenience and to introduce the techniques used in our subsequent hardness results. Second, we show that the PLEP problems are all tractable on probabilistic graphs of treewidth 1, i.e., directed graphs whose underlying undirected graph is a forest: this follows from a somewhat tedious dynamic programming computation. We will then show in the next two sections that, unexpectedly, this tractability result generalises to higher treewidth bounds only for some of the PLEP problems (§ 5 ), and that hardness can be shown for the others (§ 6 ).
Intractability on unbounded-treewidth probabilistic graphs. We first show that these problems are all intractable when we allow arbitrary graphs (of unbounded treewidth) as input, which justifies that we only study them on bounded-treewidth graphs afterwards:
Theorem 4.1. On probabilistic graphs, the problems P L E P X \mathrm{PLEP}^{X} PLEP X for X ∈ { ≤ , = , ≥ } X \in\{\leq, =, \geq\} X ∈ { ≤ , = , ≥ } and X ∈ { W a l k , P a t h } X \in\{\mathrm{Walk},\mathrm{Path}\} X ∈ { Walk , Path } are all # \# # P-hard, even when the target length is given in unary.
To show Theorem 4.1, we reduce from the classical problem # P P 2 D N F \#\mathrm{PP2DNF} # PP2DNF :
Definition 4.2. Let X = { X 1 , … , X n 1 } X = \{X_1, \ldots, X_{n_1}\} X = { X 1 , … , X n 1 } and Y = { Y 1 , … , Y n 2 } Y = \{Y_1, \ldots, Y_{n_2}\} Y = { Y 1 , … , Y n 2 } be two disjoint sets of variables. A positive, partitioned, 2DNF (PP2DNF) over X , Y X,Y X , Y is a Boolean formula of the form φ = ⋁ r = 1 m X i r ∧ Y j r \varphi= \bigvee_{r=1}^{m} X_{i_r} \land Y_{j_r} φ = ⋁ r = 1 m X i r ∧ Y j r , where i r ∈ { 1 , … , n 1 } i_r \in\{1,\ldots,n_1\} i r ∈ { 1 , … , n 1 } and j r ∈ { 1 , … , n 2 } j_r \in\{1,\ldots,n_2\} j r ∈ { 1 , … , n 2 } for 1 ≤ r ≤ m 1 \le r \le m 1 ≤ r ≤ m . An assignment for φ \varphi φ is a function ν : X ∪ Y → { 0 , 1 } \nu: X \cup Y \to\{0,1\} ν : X ∪ Y → { 0 , 1 } ; we call ν \nu ν satisfying if there is some 1 ≤ r ≤ m 1 \le r \le m 1 ≤ r ≤ m for which we have ν ( X i r ) = 1 \nu(X_{i_r}) = 1 ν ( X i r ) = 1 and ν ( Y j r ) = 1 \nu(Y_{j_r}) = 1 ν ( Y j r ) = 1 . The problem #PP2DNF takes as input such a PP2DNF φ \varphi φ and outputs # φ \#\varphi # φ , the number of satisfying assignments of φ \varphi φ .
The #PP2DNF problem is known to be #P-hard [31 ] . We can now show Theorem 4.1 :
Proof sketch of Theorem 4.1 . We use a standard construction, used for instance to show the hardness of some conjunctive queries on probabilistic databases [34 Theorem 3.2] . We code the PP2DNF formula as a bipartite graph, with variables X X X and Y Y Y as nodes respectively in the first and second partition, and connecting an X X X -variable to a Y Y Y -variable by an edge of probability 1 1 1 if they occur together in a term. We then add a source vertex s s s connected to all variables X X X by edges of probability 1 2 \frac{1}{2} 2 1 , and likewise a target vertex t t t probabilistically connected to all variables Y Y Y . The probability that there exists a walk or path from s s s to t t t having length at most, at least, or exactly 3 3 3 is then easily seen to be equal to # φ 2 ∣ Vars ( φ ) ∣ \frac{\#\varphi}{2^{|\operatorname{Vars}(\varphi)|}} 2 ∣ Vars ( φ ) ∣ # φ .
Tractability on treewidth-1 probabilistic graphs. As a first step towards studying bounded-treewidth probabilistic graphs, we now show that all six PLEP problems are tractable on treewidth-1 probabilistic graphs (i.e., probabilistic forests). We will be able to generalise this result to higher constant treewidth bounds in Section 5 for some problems only; by contrast we will show in Section 6 that for the other problems they do not generalise:
Theorem 4.3. For probabilistic graphs of treewidth 1 1 1 , the problems PLEP ⋈ X \operatorname{PLEP}^{X}_{\bowtie} PLEP ⋈ X for ⋈ ∈ { ≤ , = , ≥ } \bowtie\in\{\le, =, \ge\} ⋈∈ { ≤ , = , ≥ } and X ∈ { Walk , Path } X \in\{\operatorname{Walk}, \operatorname{Path}\} X ∈ { Walk , Path } can all be solved in linear time, up to the cost of arithmetic operations.
Proof sketch. As G \mathcal{G} G has treewidth one, there is at most one directed path from s s s to t t t . If no such path exists then the answer is zero, otherwise call the path P P P . The problems PLEP = Path \operatorname{PLEP}^{\operatorname{Path}}_{=} PLEP = Path , PLEP ≤ Path \operatorname{PLEP}^{\operatorname{Path}}_{\le} PLEP ≤ Path (equivalently PLEP ≤ Walk \operatorname{PLEP}^{\operatorname{Walk}}_{\le} PLEP ≤ Walk ), and PLEP ≥ Path \operatorname{PLEP}^{\operatorname{Path}}_{\ge} PLEP ≥ Path are then easy to solve, by first determining the length m m m of P P P , then comparing m m m to the target input length ℓ \ell ℓ , and returning, depending on this comparison, either 0 0 0 , or the probability that P P P exists (i.e., the product of the probabilities of its edges). For PLEP = Walk \operatorname{PLEP}^{\operatorname{Walk}}_{=} PLEP = Walk , if m > ℓ m > \ell m > ℓ we can return 0 0 0 and if m = ℓ m = \ell m = ℓ we can again return the probability that P P P exists. Otherwise, we need that all edges of P P P exist, but we must also take into account the possibility to have, in a realisation of G \mathcal{G} G , a path from s s s to t t t which is not simple and achieves the requisite length. If m m m and ℓ \ell ℓ do not have the same parity, this can only be achieved thanks to a self-loop, either on a vertex of P P P or on some other vertex reached by a back-and-forth excursion. Whenever this is possible, then we can get arbitrarily long walks, but we must consider whether the excursion is doable without exceeding the target length. If m m m and ℓ \ell ℓ have the same parity, it is additionally possible to lengthen the walk by multiples of two by doing a back-and-forth either on an edge dangling from the path P P P or using some return edge for an edge of P P P . These probabilities can all be computed in linear time by dynamic programming if we define the events carefully enough to ensure that they are independent. The case of PLEP ≥ Walk \operatorname{PLEP}^{\operatorname{Walk}}_{\ge} PLEP ≥ Walk is similar.
Tractable Cases on Bounded-Treewidth Probabilistic Graphs
This section contains two results. The first one, whose proof we will sketch in detail in the rest of the section, is that when the input probabilistic graphs have bounded treewidth, all PLEP problems except the “exact-length” variants are tractable.
Theorem 5.1. For any constant k k k , the problems PLEP ⋈ X \operatorname{PLEP}^{X}_{\bowtie} PLEP ⋈ X for ⋈ ∈ { ≤ , ≥ } \bowtie\in\{\le,\ge\} ⋈∈ { ≤ , ≥ } and X ∈ { Walk , Path } X \in\{\operatorname{Walk}, \operatorname{Path}\} X ∈ { Walk , Path } are tractable on probabilistic graphs of treewidth at most k k k (i.e., XP parameterised by treewidth).
The second result is that, in terms of parameterised complexity, XP is likely the best one can hope for, as we show that the problem variants from Theorem 5.1 are all W[1 ] -hard, hence not FPT assuming the standard hypothesis that F P T ≠ W [ 1 ] \mathrm{FPT}\ne\mathrm{W[1]} FPT = W [ 1 ] . We show that this holds already for acyclic graphs and already when parameterising by pathwidth:
Theorem 5.2. On probabilistic acyclic graphs, the problems P L E P ⋈ X \mathrm{PLEP}^{X}_{\bowtie} PLEP ⋈ X for ⋈ ∈ { ≤ , ≥ } \bowtie\in\{\le,\ge\} ⋈∈ { ≤ , ≥ } and X ∈ { W a l k , P a t h } X \in\{\mathrm{Walk},\mathrm{Path}\} X ∈ { Walk , Path } are W [ 1 ] \mathrm{W[1]} W [ 1 ] -hard (under Turing reductions) parameterised by pathwidth (hence also by treewidth).
Proof sketch. The reduction is done in two steps, starting from the problem of counting linear extensions of a partially ordered set (poset) P \mathcal{P} P , that we write # L E \#\mathrm{LE} # LE , which is W[1 ] -hard parameterised by pathwidth [24 ] .2 The main idea of this proof was obtained with an LLM; we digested the proof and simplified its presentation. The technique is very reminiscent of the # P \#\mathrm{P} # P -hardness proof of [8 ] (in their different context with probabilistic continuous edge lengths). Their proof relies on the hardness of counting linear extensions of posets of height 2, and an additional trick (similar to what is done in [22 Section 2] ) allows us to reduce instead from # L E \#\mathrm{LE} # LE .
We now sketch the reduction. We first reduce # L E \#\mathrm{LE} # LE to the problem of counting the number of order-preserving maps of a poset into a chain. For a poset P = ( A , ≤ P ) \mathcal{P}=(A,\le_{\mathcal{P}}) P = ( A , ≤ P ) and q ≥ 2 q\ge2 q ≥ 2 , a q q q -order-preserving map is a function f : A → { 1 , … , q } f:A\to\{1,\ldots,q\} f : A → { 1 , … , q } such that f ( x ) ≤ f ( y ) f(x)\le f(y) f ( x ) ≤ f ( y ) whenever x ≤ P y x\le_{\mathcal{P}} y x ≤ P y , and the order polynomial of P \mathcal{P} P is the function that counts the number of such q q q -order-preserving maps. This first reduction relies on the known fact that the leading coefficient of the order polynomial of P \mathcal{P} P is equal to its number of linear extensions, divided by ∣ P ∣ ! |\mathcal{P}|! ∣ P ∣ ! , so we can recover it via polynomial interpolation, through a Turing reduction that uses polynomially many calls to the oracle.
Second, we reduce this latter problem to our problem, with a reduction that again uses polynomially many calls to the target problem to recover the number of order-preserving maps. In fact, we use a variant of our problems where we instead simply count the number of realisations that contain a given number of edges and that satisfy the path length constraint, which we show to be reducible to our problem under Turing reductions again via standard polynomial interpolation techniques (see, e.g., [21 Proof of Proposition 3.1] , or [15 Appendix A] ; we prove it as Lemma C.1).
The second step of the reduction is illustrated in Figure 1 : we code the poset as a bipartite graph where every covering relation x < P y x<_{\mathcal{P}}y x < P y of P \mathcal{P} P gives a non-probabilistic edge ( u x , v y ) (u_x,v_y) ( u x , v y ) and further every vertex gives a non-probabilistic edge ( u x , v x ) (u_x,v_x) ( u x , v x ) . We then have probabilistic edges that give paths of every possible length from s s s to each u x u_x u x and from each v x v_x v x to t t t . We can show that, on realisations satisfying the path length requirements, the ( u x , v x ) (u_x,v_x) ( u x , v x ) edges force us to discard at least some number of probabilistic edges: our restriction to realisations that contain a given number of edges then enforces that we make consistent choices so that we can assign each element of P \mathcal{P} P to a position. The ( u x , v y ) (u_x,v_y) ( u x , v y ) edges then enforce that this assignment corresponds to an order-preserving map.
Figure 1. Example construction of the graph G G G from the proof of Proposition C.5, for q = 4 q = 4 q = 4 and for the poset P \mathcal{P} P containing three elements x x x , y y y and z z z , with x ≤ P z x \leq_{\mathcal{P}} z x ≤ P z and y ≤ P z y \leq_{\mathcal{P}} z y ≤ P z and x x x and y y y being incomparable. The dotted blue lines are the coding edges , which are defined in the proof and intuitively correspond to probabilistic edges.
Note that this is in contrast with the non-probabilistic case, which as we recalled is FPT (Theorem 3.1 ), and also with the fact that ST-CON is FPT parameterised by treewidth on probabilistic graphs. We now focus on proving Theorem 5.1 in this section, before turning in the next section to the intractability of the exact-length variants.
We first deal with the at-most-length variants (for both paths and walks), which follows a dynamic-programming approach and introduces the key ideas. We then adapt this to the at-least-length variant for walks following similar lines. We last cover the more complicated case of the at-least-length variant for simple paths: there the dynamic programming algorithm is more elaborate (to handle both the length requirements and the simple-path requirements), in particular it generalises the tractability of P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\ge} PLEP ≥ Path (see Theorem 3.1 ) to probabilistic graphs.
Before we start, we quickly generalise the notation G b G_b G b to probabilistic graphs in the expected way, as follows. For G G G a probabilistic graph with underlying non-probabilistic graph G G G , for S = ( S , { S b } b ∈ V ( S ) ) S=(S,\{S_b\}_{b\in V(S)}) S = ( S , { S b } b ∈ V ( S ) ) a tree decomposition of G G G , and for b b b a node of S S S , we write G b G_b G b whose underlying non-probabilistic graph is G b G_b G b and where the edge probabilities are as indicated by G G G . Notice that, by the properties of nice tree decompositions, if b b b is a Join node with children b 1 , b 2 b_1, b_2 b 1 , b 2 , then the probability distribution of G b G_b G b is the independent product of those of G b 1 G_{b_1} G b 1 and G b 2 G_{b_2} G b 2 .
At-Most Length Variants: PLEPPath≤ _{\leq} ≤ and PLEPWalk≤ _{\leq} ≤
Remember that PLEPPath≤ _{\leq} ≤ and PLEPWalk≤ _{\leq} ≤ are different names for the exact same problem; we will use the name PLEPPath≤ _{\leq} ≤ here. Further note that in our subsequent discussion we shall assume without loss of generality that ℓ < ∣ V ∣ \ell< |V| ℓ < ∣ V ∣ . This is because if ℓ ≥ ∣ V ∣ \ell\geq|V| ℓ ≥ ∣ V ∣ , then the probability that a path of length at most ℓ \ell ℓ exists is the same as the probability that a path of length at most ∣ V ∣ − 1 |V| - 1 ∣ V ∣ − 1 exists, hence it suffices to look at the instances where ℓ < ∣ V ∣ \ell< |V| ℓ < ∣ V ∣ .
To prove Theorem 5.1 in the case of PLEPPath≤ _{\leq} ≤ , we introduce an intermediate problem, that we call the shortest length probability distribution computation problem (SLPDC). The plan is to then reduce PLEPPath≤ _{\leq} ≤ to SLPDC, and then to show that SLPDC is tractable on probabilistic graphs of bounded treewidth.
Shortest Length Probability Distribution Computation. In the shortest length probability distribution computation problem, we are given a probabilistic graph G G G , two vertices s s s and t t t , and our aim is to compute, for every integer ℓ \ell ℓ ranging from 0 to ∣ V ∣ − 1 |V| - 1 ∣ V ∣ − 1 , the probability that the length of the shortest path from s s s to t t t is ℓ \ell ℓ . In addition, we will want to compute the probability that no path from s s s to t t t exists at all: in this case we say that the shortest path length from s s s to t t t is ⊥ \bot ⊥ . Formally:
PROBLEM : SLPDC (Shortest Length Probability Distribution Computation )
INPUT : A probabilistic graph G = ( V , E , π ) G = (V, E, \pi) G = ( V , E , π ) , two vertices s , t ∈ V s,t \in V s , t ∈ V
OUTPUT : For every ℓ ∈ { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } \ell\in\{0,1,\ldots,|V|-1\} \cup\{\bot\} ℓ ∈ { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } the probability that the shortest path from s s s to t t t is of length ℓ \ell ℓ
We now reduce PLEPPath≤ _{\leq} ≤ to SLPDC. Let G G G be a probabilistic graph. Consider the SLPDC output for G G G and the vertices s s s and t t t , seen as a table T T T with T [ ℓ ] T[\ell] T [ ℓ ] giving the probability that the shortest path from s s s to t t t has length ℓ \ell ℓ , for ℓ ∈ { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } \ell\in\{0,1,\ldots,|V|-1\} \cup\{\bot\} ℓ ∈ { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } . Since all of these correspond to mutually exclusive events, the probability that there is a path of length at most ℓ \ell ℓ from s s s to t t t can simply be computed as ∑ k = 0 ℓ T [ k ] \sum_{k=0}^{\ell} T[k] ∑ k = 0 ℓ T [ k ] . Therefore, to prove Theorem 5.1 in the case of PLEPPath≤ _{\leq} ≤ , it suffices to obtain a polynomial time algorithm for SLPDC on bounded-treewidth probabilistic graphs. The key idea is to compute the distribution over shortest path length functions for each node of the tree decomposition; we explain this next.
Shortest path length functions. Given a graph G = ( V , E ) G=(V,E) G = ( V , E ) , define the shortest path length function for G G G , written S P L G : V × V → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } \mathrm{SPL}_G: V \times V \to\{0,1,\ldots,|V|-1\}\cup\{\bot\} SPL G : V × V → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , to be the function such that for every u , v ∈ V u,v\in V u , v ∈ V , the value S P L G ( u , v ) \mathrm{SPL}_G(u,v) SPL G ( u , v ) equals the length of a shortest path from u u u to v v v in G G G , and ⊥ \bot ⊥ if no path from u u u to v v v exists. For A ⊆ V A\subseteq V A ⊆ V a set of vertices of G G G , we denote by S P L G , A \mathrm{SPL}_{G,A} SPL G , A the restriction of S P L G \mathrm{SPL}_G SPL G to the domain A × A A\times A A × A .
Let G \mathcal{G} G be the probabilistic graph given as input of SLPDC, with S = ( S , { S b } b ∈ V ( S ) ) \mathcal{S}=(S,\{S_b\}_{b\in V(S)}) S = ( S , { S b } b ∈ V ( S ) ) a nice tree decomposition. The key idea to solve SLPDC is to compute, by bottom-up induction on S \mathcal{S} S , for every node b b b of S \mathcal{S} S and for every possible function f : S b × S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f:S_b\times S_b\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} f : S b × S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , the probability that, in a random realisation H b H_b H b of G b \mathcal{G}_b G b , the function f f f is precisely equal to S P L H b , S b \mathrm{SPL}_{H_b,S_b} SPL H b , S b . Note that, because there are ∣ V ∣ O ( t w ( G ) ) |V|^{O(\mathrm{tw}(G))} ∣ V ∣ O ( tw ( G )) such functions for each node b b b , the resulting algorithm will be in XP parameterised by treewidth, and not FPT as was the case of Theorem 3.1 for non-probabilistic graphs. Formally:
Claim 5.3. We can compute in XP parameterised by the treewidth of G \mathcal{G} G , for each bag S b S_b S b of S \mathcal{S} S , a table T b T_b T b indexed with all possible functions f : S b × S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f:S_b\times S_b\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} f : S b × S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } such that T b [ f ] T_b[f] T b [ f ] equals the probability that in a random realisation H b H_b H b of G b \mathcal{G}_b G b , the function S P L H b , S b \mathrm{SPL}_{H_b,S_b} SPL H b , S b is equal to f f f .
Proof sketch. We proceed by bottom-up induction, and use the fact that S b S_b S b is a separator of G b G_b G b in order to be able to multiply the probabilities of events that are independent, and the fact that the information we compute is precise enough so that we can sum over mutually exclusive events. More precisely, each realisation H b H_b H b of G b \mathcal{G}_b G b contributes to precisely one cell of the table T b T_b T b . Moreover, each realisation H b H_b H b of G b \mathcal{G}_b G b of a Join node b b b with children b 1 b_1 b 1 and b 2 b_2 b 2 can be obtained by picking independently realisations H b 1 H_{b_1} H b 1 and H b 2 H_{b_2} H b 2 of G b 1 \mathcal{G}_{b_1} G b 1 and G b 2 \mathcal{G}_{b_2} G b 2 , and then the shortest path length function S P L H b , S b \mathrm{SPL}_{H_b,S_b} SPL H b , S b is entirely determined from the shortest path length functions S P L H b 1 , S b 1 \mathrm{SPL}_{H_{b_1},S_{b_1}} SPL H b 1 , S b 1 and S P L H b 2 , S b 2 \mathrm{SPL}_{H_{b_2},S_{b_2}} SPL H b 2 , S b 2 of the children. Indeed, shortest paths in H b H_b H b between vertices of S b = S b 1 = S b 2 S_b=S_{b_1}=S_{b_2} S b = S b 1 = S b 2 can be decomposed into some combination of shortest paths in H b 1 H_{b_1} H b 1 between vertices of S b 1 S_{b_1} S b 1 and shortest paths in H b 2 H_{b_2} H b 2 between vertices of S b 2 S_{b_2} S b 2 , all of which are shortest paths. Hence, the total probability of the realisations H b H_b H b achieving a specific shortest path length function can be computed by the total probability of the realisations H b 1 H_{b_1} H b 1 and H b 2 H_{b_2} H b 2 achieving specific shortest path length functions.
Once we have this, it is then easy to see that we can solve SLPDC on probabilistic graphs of bounded treewidth in XP as well. Indeed, take a nice tree decomposition of G \mathcal{G} G whose root bag is precisely { s , t } \{s,t\} { s , t } , and then we apply the algorithm underlying Claim 5.3 on the root bag. What we get as a result is, for every possible function f : { s , t } 2 → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f:\{s,t\}^2\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} f : { s , t } 2 → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , a value T [ f ] T[f] T [ f ] that is the probability that in a random realisation H H H of G \mathcal{G} G , f f f equals S P L H , { s , t } \mathrm{SPL}_{H,\{s,t\}} SPL H , { s , t } . Now, since these are mutually exclusive events, for ℓ ∈ { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } \ell\in\{0,1,\ldots,|V|-1\}\cup\{\bot\} ℓ ∈ { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } the probability that the shortest path from s s s to t t t is of length ℓ \ell ℓ is simply given by ∑ g T [ g ] \sum_g T[g] ∑ g T [ g ] , for g g g ranging over all functions g : { s , t } 2 → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } g:\{s,t\}^2\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} g : { s , t } 2 → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } such that g ( s , t ) = ℓ g(s,t)=\ell g ( s , t ) = ℓ . This concludes the proof (sketch) of Theorem 5.1 in the case of P L E P ≥ P a t h \mathrm{PLEP}_{\geq}^{\mathrm{Path}} PLEP ≥ Path .
At-Least Length Walk Variant: P L E P ≥ W a l k \mathrm{PLEP}_{\geq}^{\mathrm{Walk}} PLEP ≥ Walk
For P L E P ≥ W a l k \mathrm{PLEP}_{\geq}^{\mathrm{Walk}} PLEP ≥ Walk we can modify the algorithm of the previous section for P L E P ≤ P a t h \mathrm{PLEP}_{\leq}^{\mathrm{Path}} PLEP ≤ Path such that, for every node b b b in the tree decomposition, we compute for every function f f f from S b × S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ∞ , ⊥ } S_b\times S_b\to\{0,1,\ldots,|V|-1\}\cup\{\infty,\bot\} S b × S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ∞ , ⊥ } , the probability that f f f represents the longest walk function, i.e., for every pair u , v u,v u , v of vertices, f ( u , v ) f(u,v) f ( u , v ) represents the longest walk length from vertex u u u to v v v in a random realisation of G b \mathcal{G}_b G b . Note the additional possible value f ( u , v ) = ∞ f(u,v)=\infty f ( u , v ) = ∞ , which means that there are arbitrarily long walks from u u u to v v v , i.e., there is some cycle which is reachable from u u u and from which v v v can be reached. Thus, the main difference, apart from going from shortest paths to longest walks, is that we have to take care of detecting cycles (which then corresponds to reporting ∞ \infty ∞ ).
At-Least Length Simple Path Variant: P L E P ≥ P a t h \mathrm{PLEP}_{\geq}^{\mathrm{Path}} PLEP ≥ Path
We now explain how to show Theorem 5.1 in the case of P L E P ≥ P a t h \mathrm{PLEP}_{\geq}^{\mathrm{Path}} PLEP ≥ Path , whose proof is of a different flavour than the last two. We reuse for this the notions of path set projections that we introduced for the proof of Theorem 3.1, and combine them with the ideas used for the two other problems to correctly compute probabilities. We first note that we can again assume without loss of generality that ℓ < ∣ V ∣ \ell< |V| ℓ < ∣ V ∣ since we are looking for simple paths (if ℓ ≥ ∣ V ∣ \ell\ge|V| ℓ ≥ ∣ V ∣ we can safely return 0).
We start by defining the longest length probability distribution computation (LLPDC) problem and reduce PLEP≥ P a t h ^{\mathrm{Path}}_{\ge} ≥ Path to LLPDC.
Longest Length Probability Distribution Computation. In the longest length probability distribution computation problem, we are given a probabilistic graph G \mathcal{G} G , two vertices s s s and t t t , and our aim is to compute, for every integer ℓ \ell ℓ ranging from 0 to ∣ V ∣ − 1 |V|-1 ∣ V ∣ − 1 , the probability that the length of the longest (simple) path from s s s to t t t is ℓ \ell ℓ . In addition, we also seek to compute the probability that there does not exist a path from s s s to t t t , denoted ⊥ \bot ⊥ . Formally:
Table 1 (PDF p. 12).
It is then clear that we can reduce PLEP≥ P a t h ^{\mathrm{Path}}_{\ge} ≥ Path to LLPDC, in the same way as we reduced PLEP≤ P a t h ^{\mathrm{Path}}_{\le} ≤ Path to SLPDC. Therefore it suffices to explain how to solve LLPDC in XP for probabilistic graphs of bounded treewidth. To this end, remember the notion of path set projection from § 3 , in particular the set of tuples of vertices PSP G ( A ) \operatorname{PSP}_{G}(A) PSP G ( A ) which we defined for a graph G = ( V , E ) G=(V,E) G = ( V , E ) and set of vertices A ⊆ V A\subseteq V A ⊆ V (where A A A will be a bag). Building from this, we define the notions of candidate path set projection and of longest disjoint path length function :
Definition 5.4. For A A A a set of vertices, let C A C_A C A be the full clique over A A A , i.e. , the vertices of C A C_A C A are A A A and its edges are { ( u , v ) ∣ u , v ∈ A , u ≠ v } \{(u,v)\mid u,v\in A,u\ne v\} {( u , v ) ∣ u , v ∈ A , u = v } . We then define the set of candidate path set projections of A A A , written CPSP A \operatorname{CPSP}_A CPSP A , to be PSP C A ( A ) \operatorname{PSP}_{C_A}(A) PSP C A ( A ) .
In other words, an element of CPSP A \operatorname{CPSP}_A CPSP A is simply a set of tuples of elements of A A A such that every v ∈ A v\in A v ∈ A occurs at most once in these tuples; and CPSP A \operatorname{CPSP}_A CPSP A contains all such sets.
Definition 5.5. Let G = ( V , E ) G=(V,E) G = ( V , E ) be a graph and A ⊆ V A\subseteq V A ⊆ V . The longest disjoint path length function relative to G G G and A A A , denoted LDPL G , A : CPSP A → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } \operatorname{LDPL}_{G,A}:\operatorname{CPSP}_A\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} LDPL G , A : CPSP A → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , is the function such that, for every candidate path set projection Π ∈ CPSP A \Pi\in\operatorname{CPSP}_A Π ∈ CPSP A , the value LDPL G , A ( Π ) \operatorname{LDPL}_{G,A}(\Pi) LDPL G , A ( Π ) is equal to the maximum length of an A A A -vertex-disjoint set of paths P \mathcal{P} P of G G G such that Proj G , A ( P ) = Π \operatorname{Proj}_{G,A}(\mathcal{P})=\Pi Proj G , A ( P ) = Π if such a P \mathcal{P} P exists, or to ⊥ \bot ⊥ otherwise.
To solve LLPDC we will then compute, for every bag S b S_b S b of the tree decomposition and every possible function f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f:\operatorname{CPSP}_{S_b}\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , the probability that in a random realisation H b H_b H b of G b G_b G b , the function f f f is precisely equal to LDPL H b , S b \operatorname{LDPL}_{H_b,S_b} LDPL H b , S b . Before we explain this, let us show that this suffices to solve LLPDC. By applying this to the root bag S b r o o t = { s , t } S_{b_{\mathrm{root}}}=\{s,t\} S b root = { s , t } , and noticing that G b r o o t = G G_{b_{\mathrm{root}}}=G G b root = G , we obtain, for every function f : CPSP S b r o o t → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f:\operatorname{CPSP}_{S_{b_{\mathrm{root}}}}\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} f : CPSP S b root → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , the probability that in a random realisation H H H of G G G , the function f f f equals LDPL H , S b r o o t \operatorname{LDPL}_{H,S_{b_{\mathrm{root}}}} LDPL H , S b root ; let us call this value T [ f ] T[f] T [ f ] . Now, let Π \Pi Π be the specific path set projection Π = { ( s , t ) } \Pi=\{(s,t)\} Π = {( s , t )} (or Π = { ( s ) } \Pi=\{(s)\} Π = {( s )} in case s = t s=t s = t ), which is in CPSP S b r o o t \operatorname{CPSP}_{S_{b_{\mathrm{root}}}} CPSP S b root . Then, for ℓ ∈ { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } \ell\in\{0,1,\ldots,|V|-1\}\cup\{\bot\} ℓ ∈ { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , the probability that the longest path from s s s to t t t in G G G has length exactly ℓ \ell ℓ is equal to ∑ g T [ g ] \sum_g T[g] ∑ g T [ g ] , where g g g ranges over all functions that map Π \Pi Π to ℓ \ell ℓ . This allows us to solve LLPDC, which we already argued is enough to solve PLEP≥ P a t h ^{\mathrm{Path}}_{\ge} ≥ Path . Thus, all that is needed to finish our XP algorithm for PLEP≥ P a t h ^{\mathrm{Path}}_{\ge} ≥ Path over bounded-treewidth probabilistic graphs is to show:
Claim 5.6. We can compute in XP parameterised by the treewidth of G G G , for every bag S b S_b S b , a table T b T_b T b indexed with all possible functions f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f:\operatorname{CPSP}_{S_b}\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , such that T b [ f ] T_b[f] T b [ f ] equals the probability that in a random realisation H b H_b H b of G b G_b G b , f f f is precisely LDPL H b , S b \operatorname{LDPL}_{H_b,S_b} LDPL H b , S b .
We show this in Appendix § 11 .§ 3 , relying again on the properties of nice tree decompositions to allow us to sum over mutually exclusive events and multiply independent events.
Intractable Cases on Treewidth-2 Probabilistic Graphs
In the previous section, we have shown that the problems P L E P ⋈ X \mathrm{PLEP}_{\bowtie}^{X} PLEP ⋈ X for ⋈ ∈ { ≤ , ≥ } \bowtie\in\{\leq,\geq\} ⋈∈ { ≤ , ≥ } and X ∈ { W a l k , P a t h } X \in\{\mathrm{Walk},\mathrm{Path}\} X ∈ { Walk , Path } are all tractable on probabilistic graphs of bounded treewidth. This was shown by designing dynamic programming algorithms that deal with partial solutions for every bag of the tree decomposition, for various notions of partial solution. At first glance then, one might think that using the same kind of techniques would get us the tractability of P L E P = P a t h \mathrm{PLEP}_{=}^{\mathrm{Path}} PLEP = Path and P L E P = W a l k \mathrm{PLEP}_{=}^{\mathrm{Walk}} PLEP = Walk . We show in this section that, somewhat unexpectedly, these two remaining problems can be # P \#\mathrm{P} # P -hard on bounded-treewidth probabilistic graphs, in fact already on pathwidth-2 probabilistic graphs. (Remember that, by contrast, they are tractable on treewidth-1 graphs by Theorem 4.3 .) To prove this, we will reduce again from # P P 2 D N F \#\mathrm{PP2DNF} # PP2DNF , recalling its definition from earlier (Definition 4.2 ). Formally:
Theorem 6.1. P L E P = P a t h \mathrm{PLEP}_{=}^{\mathrm{Path}} PLEP = Path and P L E P = W a l k \mathrm{PLEP}_{=}^{\mathrm{Walk}} PLEP = Walk are # P \#\mathrm{P} # P -hard on probabilistic graphs of pathwidth 2.
Proof sketch. We show this for P L E P = P a t h \mathrm{PLEP}_{=}^{\mathrm{Path}} PLEP = Path and observe that the same reduction works for P L E P = W a l k \mathrm{PLEP}_{=}^{\mathrm{Walk}} PLEP = Walk . Given an instance φ \varphi φ of # P P 2 D N F \#\mathrm{PP2DNF} # PP2DNF on variables X = { X 1 , … , X p } X = \{X_1,\ldots,X_p\} X = { X 1 , … , X p } , Y = { Y 1 , … , Y q } Y = \{Y_1,\ldots,Y_q\} Y = { Y 1 , … , Y q } with k k k terms of the type X i r ∧ Y j r X_{i_r} \wedge Y_{j_r} X i r ∧ Y j r , where 1 ≤ r ≤ k 1 \leq r \leq k 1 ≤ r ≤ k , we construct the probabilistic graph G = ( V , E , π ) G = (V,E,\pi) G = ( V , E , π ) described below (and illustrated in Figure 6 in the appendix).
Figure 6. Mapping an instance of #PP2DNF to a probabilistic (unweighted) graph. The edges stand for paths whose intermediate vertices are omitted for simplicity, and the number indicated in the annotation stands for the length of that path (so edges labelled 1 correspond to a single edge). For the solid edges in black, all edges of the path occur with a probability of 1; the blue dotted edges are always labelled with 1 and they occur with a probability of 1 2 \frac{1}{2} 2 1 .
Create a start vertex s s s .
Create vertices u 1 , u 2 , … , u p u_1,u_2,\ldots,u_p u 1 , u 2 , … , u p which will respectively correspond to the variables X 1 , X 2 … , X p X_1,X_2\ldots,X_p X 1 , X 2 … , X p , and create vertices v 1 , … , v q v_1,\ldots,v_q v 1 , … , v q which will respectively correspond to the variables Y 1 , … , Y q Y_1,\ldots,Y_q Y 1 , … , Y q .
Create edges with probability 1 from u 1 u_1 u 1 to u 2 u_2 u 2 , from u 2 u_2 u 2 to u 3 u_3 u 3 , and so on, with the last such edge going from u p − 1 u_{p-1} u p − 1 to u p u_p u p .
Create a vertex u u u and an edge of probability 1 from u p u_p u p to u u u .
Create paths of 2 p 2p 2 p edges with probability 1 from v 1 v_1 v 1 to v 2 v_2 v 2 , from v 2 v_2 v 2 to v 3 v_3 v 3 , and so on, with the last such path going from v q − 1 v_{q-1} v q − 1 to v q v_q v q .
For each vertex u i u_i u i with i ∈ { 1 , … , p } i \in\{1,\ldots,p\} i ∈ { 1 , … , p } , create an edge from s s s to u i u_i u i having probability 1 2 \frac{1}{2} 2 1 .
For each vertex v j v_j v j with j ∈ { 1 , … , q } j \in\{1,\ldots,q\} j ∈ { 1 , … , q } , create an edge from u u u to v j v_j v j having probability 1 2 \frac{1}{2} 2 1 .
Last, create two vertices v v v and t t t , and an edge from v q v_q v q to v v v having probability 1. Now, for each term X i r ∧ Y j r X_{i_r} \wedge Y_{j_r} X i r ∧ Y j r of the formula with 1 ≤ r ≤ k 1 \leq r \leq k 1 ≤ r ≤ k , construct a path from v v v to t t t of edges with probability 1 having length ( 2 p ) j r + i r (2p)j_r+i_r ( 2 p ) j r + i r .
Clearly G G G can be constructed in polynomial time. It is not hard to show that it has treewidth 2, and a small modification of the construction given in the appendix ensures that it has pathwidth 2. We now use the oracle for the P L E P = P a t h \mathrm{PLEP}_{=}^{\mathrm{Path}} PLEP = Path problem on G G G , to compute the probability α \alpha α that there is a path of length exactly 2 p q + p + 4 2pq+p+4 2 pq + p + 4 from s s s to t t t . We then return the value α × 2 n \alpha\times2^n α × 2 n , for n : = p + q n := p+q n := p + q the number of variables of φ \varphi φ . The proof that this reduction is correct, i.e., that α = # φ 2 n \alpha= \frac{\#\varphi}{2^n} α = 2 n # φ for # φ \#\varphi # φ the number of satisfying assignments of φ \varphi φ , can be found in Appendix D.
Weighted Graphs
We now complete our picture of the complexity landscape of PLEP problems by considering weighted probabilistic graphs , i.e., directed graphs where each edge is annotated both with a positive length (written in binary) and with a probability. The length requirements in PLEP problems now ask about the existence of simple paths or walks whose total weight (i.e., the sum of the weights of all traversed edges) matches the requirement.
Non-probabilistic weighted graphs. The presence of weights written in binary has an effect on the complexity of the PLEP problems, already in the non-probabilistic setting. For instance, whereas P L E P = W a l k \mathrm{PLEP}_{=}^{\mathrm{Walk}} PLEP = Walk was tractable on arbitrary graphs (see § 2 ) and P L E P = P a t h \mathrm{PLEP}_{=}^{\mathrm{Path}} PLEP = Path was tractable on bounded-treewidth graphs (Theorem 3.1 ), it is easy to reduce the SUBSET-SUM problem to the exactly-ℓ \ell ℓ problems, already on pathwidth-2 graphs:
Proposition 7.1. The P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk and P L E P = P a t h \mathrm{PLEP}^{\mathrm{Path}}_{=} PLEP = Path problems are NP-hard already on pathwidth-2 non-probabilistic weighted graphs.
Proof. We follow an easy reduction from the NP-hard SUBSET-SUM problem. This problem asks, given a set S = { n 1 , … , n k } S=\{n_1,\ldots,n_k\} S = { n 1 , … , n k } of natural numbers and a threshold τ \tau τ (all written in binary), whether there exists a subset S ′ S' S ′ of S S S such that ∑ i ∈ S ′ i = τ \sum_{i\in S'}i=\tau ∑ i ∈ S ′ i = τ . We construct the pathwidth-2 graph G G G shown in Figure 2 (ignoring for now the edge dashing and edge colours): formally, we have vertices v 0 , … , v k v_0,\ldots,v_k v 0 , … , v k and u 1 , … , u k u_1,\ldots,u_k u 1 , … , u k , and for each 1 ≤ i ≤ k 1\le i\le k 1 ≤ i ≤ k , we have edges of weight 1 from v i − 1 v_{i-1} v i − 1 to u i u_i u i and from u i u_i u i to v i v_i v i , and an edge of weight n i + 2 n_i+2 n i + 2 from v i − 1 v_{i-1} v i − 1 to v i v_i v i . The graph obviously has pathwidth 2, with bags { v 0 , u 1 , v 1 } , … , { v k − 1 , u k , v k } \{v_0,u_1,v_1\},\ldots,\{v_{k-1},u_k,v_k\} { v 0 , u 1 , v 1 } , … , { v k − 1 , u k , v k } . Further, there is a clear bijection between the paths from v 0 v_0 v 0 to v k v_k v k and the subsets S ′ S' S ′ of S S S , given by the choice of whether to go from v i − 1 v_{i-1} v i − 1 to v i v_i v i for each edge by the length-2 path of weight 2 (we say that the path does not select n i n_i n i ) or the single edge of weight n i + 2 n_i+2 n i + 2 (we say that the path selects it). Hence, the weight of such a path is 2 k + ∑ i ∈ S ′ i 2k+\sum_{i\in S'}i 2 k + ∑ i ∈ S ′ i for the subset S ′ S' S ′ of the integers that it selects. Via the bijection, this establishes that there is a path from v 0 v_0 v 0 to v k v_k v k of total weight τ + 2 k \tau+2k τ + 2 k iff there is a subset S ′ S' S ′ of S S S that sums to τ \tau τ . Thus, the problem P L E P = P a t h \mathrm{PLEP}^{\mathrm{Path}}_{=} PLEP = Path is NP-hard. As the graph is acyclic, the same immediately holds for P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk .
Figure 2. The weighted graph constructed from an instance of SUBSET-SUM in the proof of Proposition 7.1 (ignoring the colours and dashing of edges). The edges are annotated by their weights: the weight is 1 if not indicated. The same graph is reused as a probabilistic weighted graph for the proof of Proposition 7.2, with the solid edges in black occurring with a probability of 1 whereas the blue dotted edges occur with a probability of 1 2 \frac{1}{2} 2 1 .
Note that the same reduction (up to contracting the u i u_i u i vertices) shows that hardness also holds on pathwidth-1 multigraphs, i.e., graphs where we may have multiple parallel edges with the same ordered pair of endpoints but different weights.
To avoid lengthening the paper, we leave to future work a complete exploration of the complexity landscape of PLEP problems on weighted graphs of bounded and unbounded treewidth and pathwidth. We note that the question is already intriguing in the setting of non-probabilistic graphs. Another interesting question would be to compare the setting of non-probabilistic weighted graphs to that of probabilistic non-weighted graphs, but there one can already remark that the tractable cases are not identical. For instance, the problems P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\leq} PLEP ≤ Path and P L E P ≤ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\leq} PLEP ≤ Walk are intractable on non-weighted probabilistic graphs (with or without weights; see Theorem 4.1 ), but they can be easily solved on weighted non-probabilistic graphs by computing shortest paths (e.g., via Dijkstra’s algorithm).
Our goal in the remainder of this section is simply to showcase how our previous tractability proofs on bounded-treewidth probabilistic graphs rely on the absence of edge weights, by giving some illustrative results and leaving a more complete study to future work. We will first show that all our problem variants are #P-hard on probabilistic weighted graphs, even when the input is assumed to have pathwidth at most 2. Then, we will show that the problem P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk is #P-hard already on probabilistic weighted graphs of pathwidth 1.
Hardness on pathwidth-2 graphs
We show the following result:
Proposition 7.2. All PLEP variants are #P-hard on probabilistic weighted graphs, even when the input graphs are required to have pathwidth at most 2.
By Theorem 6.1, we know that P L E P = P a t h \mathrm{PLEP}^{\mathrm{Path}}_{=} PLEP = Path and P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk are #P-hard, so it suffices to show this for the ≤ \le ≤ -variants and the ≥ \ge ≥ -variants. We reduce from the #P-hard #KNAPSACK problem [11 ] :
Definition 7.3. The problem #KNAPSACK asks, given a set of natural numbers S = { n 1 , … , n k } S = \{n_1,\ldots,n_k\} S = { n 1 , … , n k } and a threshold τ \tau τ , all written in binary, how many subsets S ′ ⊆ S S' \subseteq S S ′ ⊆ S satisfy ∑ i ∈ S ′ i ≤ τ \sum_{i\in S'} i \le\tau ∑ i ∈ S ′ i ≤ τ .
We can now show Proposition 7.2:
Proof sketch. We focus on P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\le} PLEP ≤ Path and P L E P ≤ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\le} PLEP ≤ Walk . Given an instance S , τ S,\tau S , τ of #KNAPSACK, we build a graph G G G similarly to the proof of Proposition 7.1, but some edges are made probabilistic – see Figure 2 for an illustration. The realisations of G G G then correspond to subsets of S S S , and we can ensure that the subset sums up to at most τ \tau τ iff the corresponding realisation has some path of weight at most τ + 2 k \tau+ 2k τ + 2 k from v 0 v_0 v 0 to v k v_k v k . For P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\ge} PLEP ≥ Path and P L E P ≥ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\ge} PLEP ≥ Walk , we do a variant of this reduction.
Hardness on pathwidth-1 graphs. We now show that the P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk problem, which was PTIME on pathwidth-1 probabilistic graphs (Theorem 4.3 ), becomes #P-hard when weights are allowed:
Proposition 7.4. For probabilistic weighted graphs of pathwidth 1, P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk is #P-hard.
We will show this by reduction from a counting problem that we dub #UBK. It is derived from the UBK problem, which is known to be NP-hard [26 ] :
Definition 7.5. The UBK problem is the computational problem where we are given a set S = { n 1 , … , n k } S = \{n_1,\ldots,n_k\} S = { n 1 , … , n k } of integers and an integer τ \tau τ (all given in binary), and we must decide whether there is a linear combination of the n i n_i n i with nonnegative integer coefficients that sums to τ \tau τ , i.e., whether there exist nonnegative integers u 1 , … , u k u_1,\ldots,u_k u 1 , … , u k such that ∑ i u i n i = τ \sum_i u_i n_i = \tau ∑ i u i n i = τ .
In #UBK, we are given a UBK instance S , τ S,\tau S , τ and we must count the number of subsets S ′ ⊆ S S' \subseteq S S ′ ⊆ S such that S ′ , τ S',\tau S ′ , τ is a positive UBK instance. In other words:
Definition 7.6. The problem #UBK takes as input a set of natural numbers S = { n 1 , … , n k } S = \{n_1,\ldots,n_k\} S = { n 1 , … , n k } and a threshold τ \tau τ , all written in binary, and it outputs the number of subsets S ′ S' S ′ of S S S that are feasible, i.e., such that there exist nonnegative integers u 1 , … , u k u_1,\ldots,u_k u 1 , … , u k which ensure that u i = 0 u_i = 0 u i = 0 whenever n i ∉ S ′ n_i \notin S' n i ∈ / S ′ and that ∑ i = 1 k n i u i = τ \sum_{i=1}^{k} n_i u_i = \tau ∑ i = 1 k n i u i = τ .
With standard techniques and some effort, we can show the hardness of #UBK by reducing from a variant of #PP2DNF [1 ] :
Proposition 7.7. The #UBK problem is #P-hard.
We can then show Proposition 7.4 by giving a natural reduction from #UBK to P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk on probabilistic weighted graphs of treewidth 1.
Proof sketch of Proposition 7.4. From a # U B K \#\mathrm{UBK} # UBK instance S = { n 1 , … , n k } S = \{n_1,\ldots,n_k\} S = { n 1 , … , n k } with target τ \tau τ , we build the weighted probabilistic graph of Figure 3 , where precisely one edge of each back-and-forth path from the centre vertex s s s has probability 1 / 2 1/2 1/2 . We then ask for the existence of a walk of length exactly 2 τ 2\tau 2 τ from s s s to itself. It is not hard to see that the realisations of the probabilistic weighted graph having such a walk precisely correspond to the feasible subsets of S S S .
Figure 3. The probabilistic weighted graph constructed from an instance of #UBK in the proof of Proposition 7.4. The edges are annotated by their weights. The solid edges in black occur with a probability of 1 whereas the blue dotted edges occur with a probability of 1 2 \frac{1}{2} 2 1
We remark that we expect P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk to be the only problem among our variants to be # P \#\mathrm{P} # P -hard on treewidth-1 weighted probabilistic graphs, i.e., we do not expect an analogue of Proposition 7.4 for other problem variants, and expect that they are in fact tractable. Indeed, all simple-path problem variants are tractable because there is at most one witnessing path in a treewidth-1 instance, and the problem P L E P ≤ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\leq} PLEP ≤ Walk is easy because it suffices to consider shortest paths which are again unique in treewidth-1 instances. We last expect that P L E P ≥ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\geq} PLEP ≥ Walk is in PTIME by an adaptation of the argument of Theorem 4.3 . However, we leave the detailed study of this to future work.
Conclusion and Future Work
We conclude the paper by summing up the results that we have achieved, before mentioning some possible directions for future work.
Summary. All PLEP problems are # P \#\mathrm{P} # P -hard on arbitrary probabilistic graphs (Theorem 4.1 ), with P L E P = P a t h \mathrm{PLEP}^{\mathrm{Path}}_{=} PLEP = Path and P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk being hard already on probabilistic graphs of pathwidth 2 (Theorem 6.1). The problems P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\leq} PLEP ≤ Path , P L E P ≤ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\leq} PLEP ≤ Walk , P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\geq} PLEP ≥ Path and P L E P ≥ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\geq} PLEP ≥ Walk are, on the other hand, all tractable on probabilistic graphs of bounded treewidth (Theorem 5.1 ): they are in XP parameterised by treewidth, but W[1 ] -hard parameterised by pathwidth. Further, P L E P = P a t h \mathrm{PLEP}^{\mathrm{Path}}_{=} PLEP = Path and P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk are also tractable on probabilistic graphs of treewidth 1 (Theorem 4.3 ). When we additionally add binary weights on the edges, all problems become hard for pathwidth 2 (Proposition 7.2), with P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk being hard already for pathwidth 1 (Proposition 7.4).
Future work. Our work leaves open many intriguing questions. Can we show, for instance, that bounding the treewidth of graphs is a necessary condition to obtain the tractability of P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\leq} PLEP ≤ Path , P L E P ≤ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\leq} PLEP ≤ Walk , P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\geq} PLEP ≥ Path and P L E P ≥ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\geq} PLEP ≥ Walk ? In other words, can we show that these problems are hard whenever the probabilistic graph family has unbounded treewidth, as is the case for instance for the problems studied in [3 , 6 ] ? A related question would be to show hardness in the uniform reliability setting where the input probabilistic graphs only allow edges of probability 1 / 2 1/2 1/2 (in particular allowing no edges of probability 1), in the spirit of [5 ] . This should be contrasted with the symmetric setting where the graph is a complete graph with all edges having the same probability (i.e., we also do not allow the probability 0), which sometimes makes probabilistic query evaluation tractable [12 ] .
We also leave to future work the task to complete the picture when we have binary edge weights in the non-probabilistic setting: we showed in Proposition 7.1 that P L E P = P a t h \mathrm{PLEP}^{\mathrm{Path}}_{=} PLEP = Path and P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk are hard on treewidth-2 graphs, and we know that P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\leq} PLEP ≤ Path , as well as P L E P ≤ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\leq} PLEP ≤ Walk , are tractable on arbitrary weighted non-probabilistic graphs; this leaves open the P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\geq} PLEP ≥ Path variant, which is NP-hard even without weights but which we expect to be FPT parameterised by treewidth.
Another question left to future work is whether the W[1 ] -hardness results of Theorem 5.2 could be strengthened to also establish # W [ 1 ] \#\mathrm{W}[1] # W [ 1 ] -hardness. We note that this question is explicitly left open for the source problem from which we reduce in the proof of Theorem 5.2 (counting linear extensions parameterised by pathwidth or treewidth); see [24 Section 5] .
Last, one could ask whether there is some quantitative version of MSO that would capture the tractability of our problems on bounded-treewidth probabilistic graphs, e.g., MSO with counting quantifiers as in [28 , 27 ] . However, this seems unlikely because such a logic would have to capture precisely the tractable variants and not the intractable ones, i.e., it should not capture P L E P = P a t h \mathrm{PLEP}^{\mathrm{Path}}_{=} PLEP = Path and P L E P = W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk which are hard for pathwidth 2.
Proofs for Section 3 (Treewidth)
In this section we describe what are nice tree decompositions. Intuitively, these are tree decompositions in which vertices and edges are introduced one-by-one, to simplify the design of dynamic programming algorithms. A nice tree decomposition of width k k k of a graph G = ( V , E ) G=(V,E) G = ( V , E ) is a tree decomposition S = ( S , { S b } b ∈ V ( S ) ) \mathcal{S}=(S,\{S_b\}_{b\in V(S)}) S = ( S , { S b } b ∈ V ( S ) ) of width k k k of G G G where each node b ∈ S b\in S b ∈ S is of one of the following five types:
Leaf node: b b b has no children and S b = ∅ S_b=\varnothing S b = ∅ .
Introduce Vertex node: b b b has exactly one child b ′ b' b ′ and S b = S b ′ ∪ { v } S_b=S_{b'}\cup\{v\} S b = S b ′ ∪ { v } for some v ∈ V v\in V v ∈ V .
Join node: b b b has exactly two children b 1 b_1 b 1 and b 2 b_2 b 2 and S b = S b 1 = S b 2 S_b=S_{b_1}=S_{b_2} S b = S b 1 = S b 2 .
Forget Vertex node: b b b has exactly one child b ′ b' b ′ and S b = S b ′ ∖ { v } S_b=S_{b'}\setminus\{v\} S b = S b ′ ∖ { v } for some v ∈ V v\in V v ∈ V .
Introduce Edge node: b b b has exactly one child b ′ b' b ′ such that S b = S b ′ S_b=S_{b'} S b = S b ′ , and b b b has two distinguished vertices u , v ∈ S b u,v\in S_b u , v ∈ S b such that ( u , v ) ∈ E (u,v)\in E ( u , v ) ∈ E , demarcating the addition of an edge. We say that the edge ( u , v ) ∈ E (u,v)\in E ( u , v ) ∈ E is introduced at node b b b . We additionally require that for every edge ( u , v ) ∈ E (u,v)\in E ( u , v ) ∈ E , the edge is introduced at exactly one bag.
Given a graph G = ( V , E ) G=(V,E) G = ( V , E ) and a nice tree decomposition S = ( S , { S b } b ∈ V ( S ) ) \mathcal{S}=(S,\{S_b\}_{b\in V(S)}) S = ( S , { S b } b ∈ V ( S ) ) of G G G , for any node b b b in the tree S S S , we define V b V_b V b as the set of vertices included in any of the bags contained in the subtree rooted at b b b . We further define G b G_b G b as the graph whose vertices are V b V_b V b and whose edges are exactly those that are introduced in some bag of the subtree rooted at b b b . Formally, G b = ( V b , E b ) G_b=(V_b,E_b) G b = ( V b , E b ) where E b = { e ∣ e is introduced in the subtree rooted at b } E_b=\{e\mid e\text{ is introduced in the subtree rooted at }b\} E b = { e ∣ e is introduced in the subtree rooted at b } . In particular, for b r o o t b_{\mathrm{root}} b root the root bag, we have V b r o o t = V V_{b_{\mathrm{root}}}=V V b root = V and G b r o o t = G G_{b_{\mathrm{root}}}=G G b root = G . We will use the following result, from [16 ] :
Lemma 3.2 ([16 ] ). There is an algorithm and a polynomial p p p which, given as input a graph G = ( V , E ) G=(V,E) G = ( V , E ) with two distinguished vertices s , t ∈ V s,t\in V s , t ∈ V and an integer k k k , determines if tw ( G ) ≤ k \operatorname{tw}(G)\le k tw ( G ) ≤ k , and if yes, computes a nice tree decomposition of G G G of width at most tw ( G ) + 1 \operatorname{tw}(G)+1 tw ( G ) + 1 whose root bag is { s , t } \{s,t\} { s , t } , in time O ( 2 p ( k ) ∣ V ∣ ) O(2^{p(k)}|V|) O ( 2 p ( k ) ∣ V ∣ ) .
Its proof intuitively follows from combining two lemmas: the fact from [16 ] that tree decompositions can be computed in FPT-linear time, and the fact from [18 ] that tree decompositions can be made nice:
Lemma A.1 ([16 ] ). There is an algorithm and a polynomial p p p such that, given as input a graph G = ( V , E ) G=(V,E) G = ( V , E ) and integer k k k , determines if tw ( G ) ≤ k \operatorname{tw}(G)\le k tw ( G ) ≤ k , and if yes, computes a tree decomposition of G G G of width tw ( G ) \operatorname{tw}(G) tw ( G ) in time O ( 2 p ( k ) ∣ V ∣ ) O(2^{p(k)}|V|) O ( 2 p ( k ) ∣ V ∣ ) .
Lemma A.2 ([18 ] ). If a graph G = ( V , E ) G=(V,E) G = ( V , E ) admits a tree decomposition of width k k k , then it also admits a nice tree decomposition of width k k k . Moreover, given a tree decomposition S \mathcal{S} S of G G G of width k k k , one can in time O ( k 2 ⋅ max ( ∣ S ∣ , ∣ V ∣ ) ) O(k^2\cdot\max(|S|,|V|)) O ( k 2 ⋅ max ( ∣ S ∣ , ∣ V ∣ )) compute a nice tree decomposition S ′ \mathcal{S}' S ′ of G G G of width k k k that has at most O ( k ∣ V ∣ ) O(k|V|) O ( k ∣ V ∣ ) nodes in O ( k 2 ⋅ max ( ∣ S ∣ , ∣ V ∣ ) ) O(k^2\cdot\max(|S|,|V|)) O ( k 2 ⋅ max ( ∣ S ∣ , ∣ V ∣ )) time.
And we will also use the following lemma to ensure that the root bag is exactly { s , t } \{s,t\} { s , t } , which is also convenient for our algorithms.
Lemma A.3. Consider a graph G = ( V , E ) G=(V,E) G = ( V , E ) , a nice tree decomposition S = ( S , { S b } b ∈ V ( S ) ) \mathcal{S}=(S,\{S_b\}_{b\in V(S)}) S = ( S , { S b } b ∈ V ( S ) ) of G G G and two vertices s , t ∈ V s,t\in V s , t ∈ V . Then we can compute in linear time in S S S another nice tree decomposition S ′ \mathcal{S}' S ′ where the root bag is exactly { s , t } \{s,t\} { s , t } and where the width of S ′ \mathcal{S}' S ′ is at most one more than the width of S S S .
Proof. We add t t t to every bag of the tree decomposition. Now there must be at least some node b b b with a bag S b S_b S b containing both s s s and t t t and potentially some other vertices. If S b = { s , t } S_b=\{s,t\} S b = { s , t } then we make b b b the root and we are done. Else, create another Forget Vertex node b ′ b' b ′ and join it to b b b . Thus, S b S_b S b and S b ′ S_{b'} S b ′ differ only by a single vertex v ∈ S b v\in S_b v ∈ S b such that v ≠ s , t v\ne s,t v = s , t . Repeat the process to form a linear chain of nodes until we arrive at a node with the corresponding bag containing only s , t s,t s , t and set it to be the root. Note that due to the addition of t t t , the bags corresponding to the Leaf nodes may no longer be empty. Hence, to preserve the nice tree decomposition property, for every Leaf node b 1 b_1 b 1 , we have S b 1 = { t } S_{b_1} = \{t\} S b 1 = { t } after the addition of t t t , so we create a new node b 2 b_2 b 2 with the corresponding bag S b 2 = ∅ S_{b_2} = \varnothing S b 2 = ∅ and attach it to b 1 b_1 b 1 . Thus b 2 b_2 b 2 is now a Leaf node and b 1 b_1 b 1 becomes an Introduce Vertex node. By following the process mentioned above we obtain another tree decomposition which is nice, contains only s s s and t t t at the root, and has width at most one more than that of S S S . It is easy to see that this procedure takes linear time.
Figure 4. The probabilistic graph G φ G_{\varphi} G φ from the proof of Theorem 4.1 . Probabilities are indicated in the middle of edges.
We can now prove Lemma 3.2:
Proof of Lemma 3.2. Given a graph G = ( V , E ) G = (V, E) G = ( V , E ) one may apply Lemma A.1 to verify if tw ( G ) ≤ k \operatorname{tw}(G) \leq k tw ( G ) ≤ k . Then, if indeed tw ( G ) ≤ k \operatorname{tw}(G) \leq k tw ( G ) ≤ k , we compute a tree decomposition S 1 S_1 S 1 of width k k k . This step takes O ( 2 p ( k ) ∣ V ∣ ) \mathcal{O}(2^{p(k)}|V|) O ( 2 p ( k ) ∣ V ∣ ) time, and so S 1 S_1 S 1 has size bounded by the same expression. Further using Lemma A.2, we may obtain from this tree decomposition a nice tree decomposition S 2 S_2 S 2 of width k k k that has at most O ( k ∣ V ∣ ) \mathcal{O}(k|V|) O ( k ∣ V ∣ ) nodes. Finally using Lemma A.3 we may compute, in linear time, another nice tree decomposition S S S where the root bag is exactly { s , t } \{s,t\} { s , t } and where the width of S S S is at most one more than the width of S 2 S_2 S 2 . Overall, up to changing the polynomial p p p if necessary, this takes O ( 2 p ( k ) ∣ V ∣ ) \mathcal{O}(2^{p(k)}|V|) O ( 2 p ( k ) ∣ V ∣ ) time, establishing the result.
Proofs for Section 4 (Introducing Probabilities)
Theorem 4.1. On probabilistic graphs, the problems PLEP ⋈ X \operatorname{PLEP}^{X}_{\bowtie} PLEP ⋈ X for ⋈ ∈ { ≤ , = , ≥ } \bowtie\in\{\leq, =, \geq\} ⋈∈ { ≤ , = , ≥ } and X ∈ { Walk , Path } X \in\{\text{Walk}, \text{Path}\} X ∈ { Walk , Path } are all # P \#P # P -hard, even when the target length is given in unary.
Proof. We first prove this result for the problem PLEP = Path \operatorname{PLEP}^{\text{Path}}_{= } PLEP = Path . Let φ \varphi φ be a PP2DNF formula as in Definition 4.2. Define for convenience n = n 1 + n 2 n = n_1 + n_2 n = n 1 + n 2 . Define G φ G_{\varphi} G φ to be the probabilistic graph having as set of vertices X ∪ Y ∪ { s , t } X \cup Y \cup\{s,t\} X ∪ Y ∪ { s , t } (with s s s and t t t being fresh nodes) and edges { ( s , X i ) ∣ 1 ≤ i ≤ n 1 } ∪ { ( Y i , t ) ∣ 1 ≤ i ≤ n 2 } ∪ { ( X i r , Y j r ) ∣ 1 ≤ r ≤ m } \{(s,X_i) \mid1 \leq i \leq n_1\} \cup\{(Y_i,t) \mid1 \leq i \leq n_2\} \cup\{(X_{i r},Y_{j r}) \mid1 \leq r \leq m\} {( s , X i ) ∣ 1 ≤ i ≤ n 1 } ∪ {( Y i , t ) ∣ 1 ≤ i ≤ n 2 } ∪ {( X i r , Y j r ) ∣ 1 ≤ r ≤ m } , with all edges of the form ( s , X i ) (s,X_i) ( s , X i ) and ( Y i , t ) (Y_i,t) ( Y i , t ) having probability 1 2 \frac{1}{2} 2 1 and all other edges having probability 1 1 1 . For instance, letting φ = ( X 1 ∧ Y 1 ) ∨ ( X 1 ∧ Y 2 ) ∨ ( X 2 ∧ Y 2 ) \varphi= (X_1 \land Y_1) \lor(X_1 \land Y_2) \lor(X_2 \land Y_2) φ = ( X 1 ∧ Y 1 ) ∨ ( X 1 ∧ Y 2 ) ∨ ( X 2 ∧ Y 2 ) , we show G φ G_{\varphi} G φ in Figure 4.
Now, let q q q be the probability that there exists a path from s s s to t t t in G φ G_{\varphi} G φ ; notice that we have q = # φ 2 n q = \frac{\#\varphi}{2^n} q = 2 n # φ , so that it is enough to argue that we can compute q q q .
Let us call our oracle to PLEP = Path \operatorname{PLEP}^{\text{Path}}_{=} PLEP = Path to determine if there exists a path of length 3 from s s s to t t t . Since all paths from s s s to t t t have length 3, if the output of the oracle is q q q , we may return q ⋅ 2 n q \cdot2^n q ⋅ 2 n as the number of satisfying solutions to the # P P 2 D N F \#\mathrm{PP2DNF} # PP2DNF formula. This concludes the proof in the case of PLEP = Path \operatorname{PLEP}^{\text{Path}}_{=} PLEP = Path .
Now, observe that since all paths from s s s to t t t have length 3 for the graph constructed in our reduction, the probability that a path/walk of length exactly 3 exists is equivalent to the probability that a path/walk of length at least/at most 3 exists, from s s s to t t t . Hence the same reduction shows that PLEP = Path \operatorname{PLEP}^{\text{Path}}_{=} PLEP = Path , PLEP ≤ Path \operatorname{PLEP}^{\text{Path}}_{\leq} PLEP ≤ Path , PLEP ≥ Path \operatorname{PLEP}^{\text{Path}}_{\geq} PLEP ≥ Path , PLEP = Walk \operatorname{PLEP}^{\text{Walk}}_{=} PLEP = Walk , PLEP ≤ Walk \operatorname{PLEP}^{\text{Walk}}_{\leq} PLEP ≤ Walk , PLEP ≥ Walk \operatorname{PLEP}^{\text{Walk}}_{\geq} PLEP ≥ Walk are all # P \#P # P -hard.
Theorem 4.3. For probabilistic graphs of treewidth 1, the problems PLEP ⋈ X \operatorname{PLEP}^{X}_{\bowtie} PLEP ⋈ X for ⋈ ∈ { ≤ , = , ≥ } \bowtie\in\{\leq, =, \geq\} ⋈∈ { ≤ , = , ≥ } and X ∈ { Walk , Path } X \in\{\text{Walk}, \text{Path}\} X ∈ { Walk , Path } can all be solved in linear time, up to the cost of arithmetic operations.
Algorithm 1 Compute probability that a probabilistic treewidth-1 graph contains an s t st s t -walk of length ℓ \ell ℓ
Input: A graph G = ( V , E , π : E → [ 0 , 1 ] ) \mathcal{G}=(V,E,\pi:E\to[0,1]) G = ( V , E , π : E → [ 0 , 1 ]) , vertices s , t s,t s , t , and an integer ℓ \ell ℓ representing the desired walk length
Output: Probability p p p that a walk of length ℓ \ell ℓ exists from s s s to t t t in G \mathcal{G} G
Let P = ( n 0 = s , n 1 , … , n k = t ) P=(n_0=s,n_1,\ldots,n_k=t) P = ( n 0 = s , n 1 , … , n k = t ) be the unique path from s s s to t t t (if no such path exists, return 0 as the probability);
if ℓ < k \ell<k ℓ < k then return 0;
end
if ℓ = k \ell=k ℓ = k then p ← ( ∏ i = 0 k − 1 π ( n i , n i + 1 ) ) p\gets\left(\prod_{i=0}^{k-1}\pi(n_i,n_{i+1})\right) p ← ( ∏ i = 0 k − 1 π ( n i , n i + 1 ) ) ;
return p p p ;
end
if ( ℓ − k ) m o d 2 = 0 (\ell-k)\bmod2=0 ( ℓ − k ) mod 2 = 0 then Q = { u 1 , u 2 , u 3 … u j } ← Q=\{u_1,u_2,u_3\ldots u_j\}\gets Q = { u 1 , u 2 , u 3 … u j } ← set of all vertices ∈ P \in P ∈ P which have a self-loop in G \mathcal{G} G ; // p Q p_Q p Q is the probability that there no vertex of P P P has a self-loop
p Q ← ∏ u ∈ Q ( 1 − π ( u , u ) ) p_Q\gets\prod_{u\in Q}(1-\pi(u,u)) p Q ← ∏ u ∈ Q ( 1 − π ( u , u )) ;
R = { ( v 1 , w 1 ) , ( v 2 , w 2 ) … ( v i , w i ) } ← R=\{(v_1,w_1),(v_2,w_2)\ldots(v_i,w_i)\}\gets R = {( v 1 , w 1 ) , ( v 2 , w 2 ) … ( v i , w i )} ← set of all vertex pairs ( v , w ) (v,w) ( v , w ) with v ∈ P v\in P v ∈ P and w ∉ P w\notin P w ∈ / P and the edges ( v , w ) (v,w) ( v , w ) and ( w , v ) (w,v) ( w , v ) exist in G \mathcal{G} G ; // p R p_R p R is the probability that there is no back-and-forth edge pair outside of P P P incident to a vertex of P P P
p R ← ∏ ( v , w ) ∈ R ( 1 − π ( v , w ) π ( w , v ) ) p_R\gets\prod_{(v,w)\in R}(1-\pi(v,w)\pi(w,v)) p R ← ∏ ( v , w ) ∈ R ( 1 − π ( v , w ) π ( w , v )) ;
S = { ( v 1 , w 1 ) , ( v 2 , w 2 ) … ( v j , w j ) } ← S=\{(v_1,w_1),(v_2,w_2)\ldots(v_j,w_j)\}\gets S = {( v 1 , w 1 ) , ( v 2 , w 2 ) … ( v j , w j )} ← set of all vertex pairs ( v , w ) (v,w) ( v , w ) with v , w ∈ P v,w\in P v , w ∈ P and the edge ( v , w ) (v,w) ( v , w ) occurs in P P P and the back edge ( w , v ) (w,v) ( w , v ) exist in G \mathcal{G} G ; // p S p_S p S is the probability that there is no return edge for any forward edge of P P P
p S ← ∏ ( v , w ) ∈ S ( 1 − π ( w , v ) ) p_S\gets\prod_{(v,w)\in S}(1-\pi(w,v)) p S ← ∏ ( v , w ) ∈ S ( 1 − π ( w , v )) ; // return probability that P P P exists and we have one self-loop on a vertex of P P P or back-and-forth on P P P or on an edge incident to P P P
return ( ∏ i = 0 k − 1 π ( n i , n i + 1 ) ) ( 1 − p Q p R p S ) \left(\prod_{i=0}^{k-1}\pi(n_i,n_{i+1})\right)(1-p_Qp_Rp_S) ( ∏ i = 0 k − 1 π ( n i , n i + 1 ) ) ( 1 − p Q p R p S ) ;
end
else // critical length to reach a self-loop and change parity
c l ← ℓ − k − 1 2 \mathrm{cl}\gets\frac{\ell-k-1}{2} cl ← 2 ℓ − k − 1 ;
foreach v ∈ P v\in P v ∈ P do // explore the tree rooted at v v v without the edges of P P P
E P ← E_P\gets E P ← edges of P P P ;
T v ← \mathcal{T}_v\gets T v ← tree rooted at v v v of the connected component of v v v in G [ E \ E P ] \mathcal{G}[E\backslash E_P] G [ E \ E P ] ; // compute the probability that we can reach a self-loop from v v v
p v ← GetExProb ( T v , v , c l ) p_v\gets\operatorname{GetExProb}(\mathcal{T}_v,v,\mathrm{cl}) p v ← GetExProb ( T v , v , cl ) ;
end // return probability that P P P exists and there is a vertex of P P P from which we can reach a self-loop
return ( ∏ i = 0 k − 1 π ( n i , n i + 1 ) ) × ( 1 − ∏ v ∈ P ( 1 − p v ) ) \left(\prod_{i=0}^{k-1}\pi(n_i,n_{i+1})\right)\times\left(1-\prod_{v\in P}(1-p_v)\right) ( ∏ i = 0 k − 1 π ( n i , n i + 1 ) ) × ( 1 − ∏ v ∈ P ( 1 − p v ) ) ;
end
Proof. Note that if a graph G = ( V , E , π ) \mathcal{G}=(V,E,\pi) G = ( V , E , π ) has treewidth 1, then it implies that either there is a unique directed path from s s s to t t t or t t t is not reachable from s s s . Indeed, otherwise the underlying undirected graph would contain a cycle, implying that its treewidth is greater than or equal to 2. Note that if it exists, this unique directed path may be found using a breadth first search in linear time in the size of the input. Thus given an instance of P L E P = P a t h \mathrm{PLEP}_{=}^{\mathrm{Path}} PLEP = Path where we need to find the probability of existence of a path of length ℓ \ell ℓ , we can check if the length of the unique directed path from s s s to t t t is ℓ \ell ℓ . If there is no s s s to t t t path or if the length of the unique directed path from s s s to t t t does not equal ℓ \ell ℓ we return 0, else we return the multiplication of the probabilities over all the edges in this path. For P L E P ≤ P a t h \mathrm{PLEP}_{\leq}^{\mathrm{Path}} PLEP ≤ Path (or equivalently P L E P ≤ W a l k \mathrm{PLEP}_{\leq}^{\mathrm{Walk}} PLEP ≤ Walk ) where the desired path length threshold is ℓ \ell ℓ , we again check if a path from s s s to t t t exists, check whether its length is less than or equal to ℓ \ell ℓ if it exists, and return 0 or the multiplication of the probabilities over all the edges in this path accordingly. A similar argument works for P L E P ≥ P a t h \mathrm{PLEP}_{\geq}^{\mathrm{Path}} PLEP ≥ Path .
The only remaining cases are P L E P ≥ W a l k \mathrm{PLEP}_{\geq}^{\mathrm{Walk}} PLEP ≥ Walk and P L E P = W a l k \mathrm{PLEP}_{=}^{\mathrm{Walk}} PLEP = Walk . We propose Algorithm 1 for P L E P = W a l k \mathrm{PLEP}_{=}^{\mathrm{Walk}} PLEP = Walk , which may be adapted to P L E P ≥ W a l k \mathrm{PLEP}_{\geq}^{\mathrm{Walk}} PLEP ≥ Walk as well. Throughout the algorithm, the probability π ( u , v ) \pi(u,v) π ( u , v ) is always implicitly 0 if there is no edge from u u u to v v v . We give more details here on why the algorithm works.
Let P P P be the unique directed path from s s s to t t t . (If no such path exists, we simply return 0). If the length of P P P is k k k , and the desired walk length threshold is ℓ \ell ℓ then the case where ℓ < k \ell< k ℓ < k is easy since there cannot exist a walk from s s s to t t t with length less than that of the unique directed path P P P . Likewise when ℓ = k \ell= k ℓ = k , the only possible walk from s s s to t t t with length ℓ \ell ℓ is P P P itself, hence in this case we return the multiplication of the probabilities associated with the edges of P P P .
We now turn to the case where ℓ > k \ell> k ℓ > k . We make two cases on the basis of the parity of ( ℓ − k ) (\ell-k) ( ℓ − k ) . Note that if ( ℓ − k ) m o d 2 = 0 (\ell-k)\bmod2=0 ( ℓ − k ) mod 2 = 0 , then a realisation G G G of G \mathcal{G} G contains a walk of length ℓ \ell ℓ from s s s to t t t if and only if at least one of these three kinds of edges is present in G G G , in addition to the directed path P P P .
There exists a vertex v ∈ P v\in P v ∈ P such that there exists a self-loop at the vertex v v v in G G G (i.e., an edge from v v v to v v v )
There exist two adjacent vertices v 1 , v 2 ∈ P v_1,v_2\in P v 1 , v 2 ∈ P such that there is an edge from v 1 v_1 v 1 to v 2 v_2 v 2 and an edge from v 2 v_2 v 2 to v 1 v_1 v 1 in G G G
There exist two vertices v 1 , v 2 v_1,v_2 v 1 , v 2 such that v 1 ∈ P v_1\in P v 1 ∈ P , v 2 ∉ P v_2\notin P v 2 ∈ / P and there exists an edge from v 1 v_1 v 1 to v 2 v_2 v 2 and an edge from v 2 v_2 v 2 to v 1 v_1 v 1 in G G G
Therefore if ( ℓ − k ) m o d 2 = 0 (\ell-k)\bmod2=0 ( ℓ − k ) mod 2 = 0 , then the required probability of a walk of length ℓ \ell ℓ from s s s to t t t being present in G G G is the probability that the path P P P is present, and at least one of these three conditions outlined above is satisfied. Note that up to the parity of ( ℓ − k ) (\ell-k) ( ℓ − k ) , these conditions are independent of the specific value of ℓ \ell ℓ .
Let us now look at the case when ( ℓ − k ) m o d 2 = 1 (\ell-k)\bmod2=1 ( ℓ − k ) mod 2 = 1 . In such a case, we can show that given a realisation G G G of G \mathcal{G} G there exists a walk of length ℓ \ell ℓ from s s s to t t t in G G G if and only if there exists a vertex v ∈ P v\in P v ∈ P such that a retraceable path of length at most ℓ − k − 1 2 \frac{\ell-k-1}{2} 2 ℓ − k − 1 exists from v v v to another vertex v ′ v' v ′ , possibly not in P P P , such that v ′ v' v ′ contains a self-loop, i.e., there is an edge from v ′ v' v ′ to v ′ v' v ′ . By a retraceable path we mean a path in G G G , where besides every forward edge ( p , q ) (p,q) ( p , q ) in that path P P P , the corresponding back edge ( q , p ) (q,p) ( q , p ) must also be present in G G G . The idea is that we can take the path P P P from s s s to v v v , diverge from v v v to v ′ v' v ′ , take the self-loop attached to v ′ v' v ′ sufficiently many times, retrace back to the vertex v v v and then continue along the path P P P from v v v to t t t . However, this self-loop cannot be located too far from v v v , in particular, if it is at a distance of greater than ℓ − k − 1 2 \frac{\ell-k-1}{2} 2 ℓ − k − 1 from v v v , then visiting v ′ v' v ′ from v v v and returning back to v v v will necessarily cause the length of the walk from s s s to t t t to exceed ℓ \ell ℓ . So in this case, the natural algorithm is to compute, for every vertex v v v on the path P P P , the probability that there is a path of length less than or equal to the maximum length c l \mathrm{cl} cl from v v v to another vertex with self-loop, where c l = ℓ − k − 1 2 \mathrm{cl}=\frac{\ell-k-1}{2} cl = 2 ℓ − k − 1 .
We compute this quantity using Algorithm 2. Intuitively, at every node w w w reachable from v v v without going through an edge of P P P and without exceeding the maximum length, letting π ( w , w ) \pi(w,w) π ( w , w ) be the probability that the current node w w w has a self-loop, then the probability that we can reach a self-loop from w w w and come back within our allotted maximum length can be expressed as follows. It is 1 if the self-loop on w w w is present, which happens with probability π ( w , w ) \pi(w,w) π ( w , w ) . Otherwise, it is the independent OR of the probabilities that we can reach a self-loop from w ′ w' w ′ for each child w ′ w' w ′ and come back, weighted by the probabilities that the edges to w ′ w' w ′ and back are present, and multiplying by the recursively computed quantity on w ′ w' w ′ with the maximum length having been decremented. Note that, here, the recursively computed probabilistic events are indeed independent because they pertain to disjoint parts of the tree. The same holds between the probabilistic events across the various choices of v v v along the path, thanks to the fact that the underlying probabilistic graph is a forest.
Now, we briefly sketch how this algorithm can be adapted to PLEP⋈ W a l k ^{\mathrm{Walk}}_{\bowtie} ⋈ Walk . Again, we find the unique directed path P P P from s s s to t t t (if it exists, else we return 0). Let its length be k k k . If the desired length ℓ \ell ℓ is such that ℓ ≤ k \ell\leq k ℓ ≤ k , then clearly such a walk exists if and only if the directed path P P P exists.
Otherwise, if ℓ > k \ell> k ℓ > k , we take the independent disjunction across all possible ways to make the walk longer than P P P . (We need not care about parity this time, because we do not need to reach a precise length.) More precisely, we take the independent disjunction across all self-loops of P P P , all back-edges corresponding to a forward edge of P P P , and all pairs of back-and-forth edges not in P P P that lead out of a vertex of P P P ; and we multiply this by the probability that all edges of P P P exist (i.e., we do precisely like the case of ( ℓ − k ) m o d 2 = 0 (\ell-k)\mathbin{\bmod}2=0 ( ℓ − k ) mod 2 = 0 in Algorithm 1).
Algorithm 2 Compute the probability that we can reach a self-loop with the indicated budget
Input: directed rooted tree T = (V_T, E_T, π : E_T → [0,1]), current node v, length budget cl
Output: Probability that we can reach a self-loop within budget cl and come back
1 Function GetExProb(T, v, cl):
2 if cl < 0 then
3 return 0;
4 end
// π(v,v) is implicitly 0 if (v,v) ∉ E
5 return
π(v,v) + (1 − π(v,v)) ×
(1 − ∏_{(v,v′),(v′,v)∈E, v′ child of v in T}
(1 − π(v,v′) · π(v′,v) · GetExProb(T, v′, cl − 1)))
Proofs for Section 5 (Tractable Cases on Bounded-Treewidth Probabilistic Graphs)
Proofs of the W[1]-Hardness Result
In this section we prove the following result.
Theorem 5.2. On probabilistic acyclic graphs, the problems PLEP⋈ X ^{X}_{\bowtie} ⋈ X for ⋈ ∈ { ≤ , ≥ } \bowtie\in\{\leq,\geq\} ⋈∈ { ≤ , ≥ } and X ∈ { W a l k , P a t h } X \in\{\mathrm{Walk},\mathrm{Path}\} X ∈ { Walk , Path } are W[1 ] -hard (under Turing reductions) parameterised by pathwidth (hence also by treewidth).
To prove this, we will need the following general tool, intuitively saying that if we can efficiently compute the probability that a randomly chosen subset of edges of a probabilistic graph has a given property, then we can also efficiently compute the number of such sets of a given cardinality that have the property. Formally a property in this context is a function that takes as input a graph G = ( V , E ) G=(V,E) G = ( V , E ) , a subset S ⊆ E S\subseteq E S ⊆ E of the edges, and some parameters Π \Pi Π , and that is either true or false for these inputs. For instance, P P P could take a graph G = ( V , E ) G=(V,E) G = ( V , E ) , a subset S ⊆ E S\subseteq E S ⊆ E , and as parameters a source s ∈ V s\in V s ∈ V and target t ∈ V t\in V t ∈ V and integer ℓ \ell ℓ , and is satisfied only if there exists a path of length ≤ ℓ \le\ell ≤ ℓ from s s s to t t t in G [ S ] G[S] G [ S ] . For such a property P P P , define the probabilistic computation problem for P P P to be the problem where the input is a probabilistic graph G = ( G = ( V , E ) , π ) \mathcal{G}=(G=(V,E),\pi) G = ( G = ( V , E ) , π ) and some parameters Π \Pi Π , and the output is the sum, across all S ⊆ E S\subseteq E S ⊆ E such that ( G , S , Π ) (G,S,\Pi) ( G , S , Π ) has the property P P P , of Pr G ( S ) \Pr_{\mathcal{G}}(S) Pr G ( S ) . Define also the generalised cardinality computation problem for P P P to take as input a graph G = ( V , E ) G=(V,E) G = ( V , E ) , a subset T ⊆ E T\subseteq E T ⊆ E , some parameters Π \Pi Π , and some natural number c ∈ N c\in\mathbb{N} c ∈ N , and the goal is to compute how many subsets S ⊆ E ∖ T S\subseteq E\setminus T S ⊆ E ∖ T of size c c c are such that ( G , T ∪ S , Π ) (G,T\cup S,\Pi) ( G , T ∪ S , Π ) satisfies property P P P . Intuitively, the edges of T T T are always present and not accounted for, i.e., they correspond to exogenous facts. We then recall the following, which is folklore (see, e.g., [21 Proof of Proposition 3.1] , or [15 Appendix A] ):
Lemma C.1. For any property P P P as above, there is a polynomial-time Turing reduction from the generalised cardinality problem for P P P to the probabilistic computation problem for P P P .
Proof. Let G = ( V , E ) G=(V,E) G = ( V , E ) , T ⊆ E T\subseteq E T ⊆ E , Π \Pi Π and c c c the input instance for the generalised cardinality problem for P P P , and let n = ∣ E ∖ T ∣ n=|E\setminus T| n = ∣ E ∖ T ∣ . For r ∈ { 0 , … , n } r\in\{0,\ldots,n\} r ∈ { 0 , … , n } define N r N_r N r to be the number of subsets S ⊆ E ∖ T S\subseteq E\setminus T S ⊆ E ∖ T of size r r r such that ( G , T ∪ S , Π ) (G,T\cup S,\Pi) ( G , T ∪ S , Π ) satisfies property P P P . We will show how to compute all the N r N_r N r values, which is enough since we only need N c N_c N c .
For z z z a natural number, define G z \mathcal{G}_z G z to be the probabilistic graph G z = ( V , E , π z ) \mathcal{G}_z=(V,E,\pi_z) G z = ( V , E , π z ) where π z ( ( v , v ′ ) ) = 1 \pi_z((v,v'))=1 π z (( v , v ′ )) = 1 for every ( v , v ′ ) ∈ T (v,v')\in T ( v , v ′ ) ∈ T and π z ( ( v , v ′ ) ) = z 1 + z \pi_z((v,v'))=\frac{z}{1+z} π z (( v , v ′ )) = 1 + z z for every ( v , v ′ ) ∈ E ∖ T (v,v')\in E\setminus T ( v , v ′ ) ∈ E ∖ T . Then, denoting O z O_z O z the result of the probabilistic computation problem for P P P on G z \mathcal{G}_z G z and Π \Pi Π , we have:
O z = ∑ S ⊆ E ( G , S , Π ) has property P Pr G z ( S ) = ∑ S ⊆ E ∖ T ( G , T ∪ S , Π ) has property P Pr G z ( T ∪ S ) = ∑ r = 0 n ∑ S ⊆ E ∖ T , ∣ S ∣ = r ( G , T ∪ S , Π ) has property P Pr G z ( T ∪ S ) = ∑ r = 0 n ∑ S ⊆ E ∖ T , ∣ S ∣ = r ( G , T ∪ S , Π ) has property P ( ∏ e ∈ S z 1 + z ) ( ∏ e ∈ E ∖ ( T ∪ S ) ( 1 − z 1 + z ) ) = ∑ r = 0 n ∑ S ⊆ E ∖ T , ∣ S ∣ = r ( G , T ∪ S , Π ) has property P ( z 1 + z ) r ( 1 1 + z ) n − r = 1 ( 1 + z ) n ∑ r = 0 n z r ∑ S ⊆ E ∖ T , ∣ S ∣ = r ( G , T ∪ S , Π ) has property P 1 = 1 ( 1 + z ) n ∑ r = 0 n z r N r . (1) \begin{aligned}
O_z
&= \sum_{\substack{S\subseteq E\\(G,S,\Pi)\text{ has property }P}} \Pr_{\mathcal{G}_z}(S) \\
&= \sum_{\substack{S\subseteq E\setminus T\\(G,T\cup S,\Pi)\text{ has property }P}} \Pr_{\mathcal{G}_z}(T\cup S) \\
&= \sum_{r=0}^{n}\sum_{\substack{S\subseteq E\setminus T,\ |S|=r\\(G,T\cup S,\Pi)\text{ has property }P}} \Pr_{\mathcal{G}_z}(T\cup S) \\
&= \sum_{r=0}^{n}\sum_{\substack{S\subseteq E\setminus T,\ |S|=r\\(G,T\cup S,\Pi)\text{ has property }P}}
\left(\prod_{e\in S}\frac{z}{1+z}\right)
\left(\prod_{e\in E\setminus(T\cup S)}\left(1-\frac{z}{1+z}\right)\right) \\
&= \sum_{r=0}^{n}\sum_{\substack{S\subseteq E\setminus T,\ |S|=r\\(G,T\cup S,\Pi)\text{ has property }P}}
\left(\frac{z}{1+z}\right)^r
\left(\frac{1}{1+z}\right)^{n-r} \\
&= \frac{1}{(1+z)^n}\sum_{r=0}^{n}z^r
\sum_{\substack{S\subseteq E\setminus T,\ |S|=r\\(G,T\cup S,\Pi)\text{ has property }P}}1 \\
&= \frac{1}{(1+z)^n}\sum_{r=0}^{n}z^rN_r. \tag*{(1)}
\end{aligned} O z = S ⊆ E ( G , S , Π ) has property P ∑ G z Pr ( S ) = S ⊆ E ∖ T ( G , T ∪ S , Π ) has property P ∑ G z Pr ( T ∪ S ) = r = 0 ∑ n S ⊆ E ∖ T , ∣ S ∣ = r ( G , T ∪ S , Π ) has property P ∑ G z Pr ( T ∪ S ) = r = 0 ∑ n S ⊆ E ∖ T , ∣ S ∣ = r ( G , T ∪ S , Π ) has property P ∑ ( e ∈ S ∏ 1 + z z ) e ∈ E ∖ ( T ∪ S ) ∏ ( 1 − 1 + z z ) = r = 0 ∑ n S ⊆ E ∖ T , ∣ S ∣ = r ( G , T ∪ S , Π ) has property P ∑ ( 1 + z z ) r ( 1 + z 1 ) n − r = ( 1 + z ) n 1 r = 0 ∑ n z r S ⊆ E ∖ T , ∣ S ∣ = r ( G , T ∪ S , Π ) has property P ∑ 1 = ( 1 + z ) n 1 r = 0 ∑ n z r N r . (1)
We then use the oracle to the probabilistic computation problem for P P P to compute values ( 1 + z ) n O z (1+z)^nO_z ( 1 + z ) n O z for n + 1 n+1 n + 1 pairwise different values of z z z . We then solve the system of linear equations given by (1) (which is invertible because its matrix is a Vandermonde matrix with pairwise different values of z z z ), to compute in polynomial time all the values N r N_r N r for r ∈ { 0 , … , n } r\in\{0,\ldots,n\} r ∈ { 0 , … , n } as we wanted. This concludes the proof. ◂
With this in place, we now focus on proving Theorem 5.2. Remember that the problems P L E P ≤ W a l k \mathrm{PLEP}^{\mathrm{Walk}}_{\leq} PLEP ≤ Walk and P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\leq} PLEP ≤ Path are the same problems. We first provide a proof of a weaker statement that applies only to P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\le} PLEP ≤ Path for general probabilistic graphs (i.e., without restricting to acyclic graphs), and then a second proof (which is the one that we sketched in the maintext) that works for all variants and only uses acyclic graphs. Both arguments were originally suggested by an LLM (but written by the authors): even though the first proof is subsumed by the second one, we give it nevertheless because it is much simpler and the source problem is different.
First Proof of W[1]-hardness for PLEPPath
First, we show that P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\le} PLEP ≤ Path is W[1 ] -hard when we consider undirected graphs (as opposed to the directed graphs we usually consider in this article). The definition of P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\le} PLEP ≤ Path on undirected graphs is the same as when we have directed graphs, except that the input is now an undirected probabilistic graph G = ( V , E , π ) \mathcal{G}=(V,E,\pi) G = ( V , E , π ) (with E E E containing pairs of the form { v , v ′ } \{v,v'\} { v , v ′ } for v , v ′ ∈ V v,v'\in V v , v ′ ∈ V , v ≠ v ′ v\ne v' v = v ′ ). We show:
Proposition C.2. On probabilistic undirected graphs, the problem P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\le} PLEP ≤ Path is W[1 ] -hard (under Turing reductions) parameterised by pathwidth.
Proof. We reduce from the Minimum Length-Bounded Cut problem (MLBC). The input to this problem is an undirected graph G = ( V , E ) G=(V,E) G = ( V , E ) , two vertices s , t ∈ V s,t\in V s , t ∈ V (called source and target), and two integers ℓ , g ∈ N \ell,g\in\mathbb{N} ℓ , g ∈ N . For a subset of edges C ⊆ E C\subseteq E C ⊆ E , we say that C C C is an ℓ \ell ℓ -cut if every path from s s s to t t t of length at most ℓ \ell ℓ contains an edge in C C C ; in other words, if s s s and t t t are at distance > ℓ >\ell > ℓ in the graph where we have removed all edges of C C C . The goal of the problem is then to determine if there exists an ℓ \ell ℓ -cut of size at most g g g . This problem has been shown to be W[1 ] -hard parameterised by pathwidth in [23 , 14 ] .
We now explain the reduction. Let G = ( V , E ) G=(V,E) G = ( V , E ) , s , t ∈ V s,t\in V s , t ∈ V , ℓ , g ∈ N \ell,g\in\mathbb{N} ℓ , g ∈ N be the input instance to MLBC, and let n = ∣ E ∣ n=|E| n = ∣ E ∣ . For c ∈ { 0 , … , n } c\in\{0,\ldots,n\} c ∈ { 0 , … , n } , define N c N_c N c to be the number of ℓ \ell ℓ -cuts of size c c c . Notice then that the goal is simply to determine if ∑ c = 0 g N c > 0 \sum_{c=0}^{g}N_c>0 ∑ c = 0 g N c > 0 . For c ∈ { 0 , … , n } c\in\{0,\ldots,n\} c ∈ { 0 , … , n } , denote by N ‾ c \overline{N}_c N c the number of subsets of size c c c of E E E that are not ℓ \ell ℓ -cuts, i.e., N ‾ c = ( n c ) − N c \overline{N}_c=\binom{n}{c}-N_c N c = ( c n ) − N c . Then, by what precedes, if we can compute all the numbers N ‾ c \overline{N}_c N c for c ∈ { 0 , … , n } c\in\{0,\ldots,n\} c ∈ { 0 , … , n } , we can solve the MLBC problem on this instance. We will do this using our oracle for P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\le} PLEP ≤ Path , and more specifically we invoke Lemma C.1 with the property P P P being the following: it takes a graph G = ( V , E ) G=(V,E) G = ( V , E ) , a subset S ⊆ E S\subseteq E S ⊆ E and parameters s , t ∈ V s,t\in V s , t ∈ V and ℓ ∈ N \ell\in\mathbb{N} ℓ ∈ N , and it is satisfied if E ∖ S E\setminus S E ∖ S is not an ℓ \ell ℓ -cut for s , t s,t s , t . The probabilistic computation problem for this property P P P is precisely our target problem P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\le} PLEP ≤ Path . Thus, via the reduction of Lemma C.1, we can use our P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\le} PLEP ≤ Path oracle to solve the generalised cardinality computation problem for P P P , i.e., to compute in polynomial time for every r ∈ { 0 , … , n } r\in\{0,\ldots,n\} r ∈ { 0 , … , n } the number of subsets S ⊆ E S\subseteq E S ⊆ E of size r r r such that E ∖ S E\setminus S E ∖ S is not an ℓ \ell ℓ -cut (we set T : = ∅ T:=\varnothing T := ∅ , as there are no exogenous facts). Since the number of subsets S ⊆ E S\subseteq E S ⊆ E of size r r r that are not an ℓ \ell ℓ -cut is equal to the number of subsets S ′ ⊆ E S'\subseteq E S ′ ⊆ E of size n − r n-r n − r such that E ∖ S ′ E\setminus S' E ∖ S ′ is not an ℓ \ell ℓ -cut, we can indeed compute in polynomial time all the numbers N ‾ c \overline{N}_c N c , as desired.
Last, we notice that the reduction is indeed a valid FPT (Turing) reduction, since the graph, in particular its pathwidth, was not modified at all. This concludes the proof.
Hence, all that is left to prove Theorem 5.2 is to explain how to adapt the proof to the directed probabilistic graphs that we study in this article. To do this, we consider essentially the same reduction from Proposition C.2, but we replace every undirected edge { v , v ′ } \{v,v'\} { v , v ′ } of the undirected graph G = ( V , E ) G=(V,E) G = ( V , E ) with the gadget shown in Figure 5 , with a { v , v ′ } a_{\{v,v'\}} a { v , v ′ } and b { v , v ′ } b_{\{v,v'\}} b { v , v ′ } being fresh vertices. (The gadget in question was proposed by an LLM but appears to be folklore, and is mentioned, e.g., to be a well known reduction in [10 Section 2] .) Call G → \overrightarrow{G} G the directed graph obtained from G G G in this fashion. Let us write U U U and D D D the coding edges set of edges of G → \overrightarrow{G} G of the form a { v , v ′ } → b { v , v ′ } a_{\{v,v'\}}\to b_{\{v,v'\}} a { v , v ′ } → b { v , v ′ } , and D D D the set of all other edges, that we call the exogenous edges. For a set of edges S ⊆ E S\subseteq E S ⊆ E , let S ′ S' S ′ be the set of coding edges of G → \overrightarrow{G} G that they correspond to, i.e., S ′ = { { a { v , v ′ } , b { v , v ′ } } ∣ { v , v ′ } ∈ S } S'=\{\{a_{\{v,v'\}},b_{\{v,v'\}}\}\mid\{v,v'\}\in S\} S ′ = {{ a { v , v ′ } , b { v , v ′ } } ∣ { v , v ′ } ∈ S } . We then observe the following: S S S is not an ℓ \ell ℓ -cut of G G G if and only if S ′ S' S ′ is not a 3 ℓ 3\ell 3 ℓ -cut of G → \overrightarrow{G} G . Adapting the reduction is then straightforward, using T → : = D \overrightarrow{T}:=D T := D in the generalised cardinality problem to force the exogenous edges not to be considered in a cut, and also noting that the transformation from G G G to G → \overrightarrow{G} G only multiplies the treewidth by a constant factor (indeed, the two fresh vertices introduced in the gadget can be added in any bag witnessing the original undirected edge, and this bag now witnesses the five directed edges of the gadget).
Figure 5. Gadget to adapt the reduction of Proposition C.2 to directed graphs.
Last, we remark here that this proof could be adapted to show the W[1 ] -hardness of the ≥ \geq ≥ -variants, if one could show that the corresponding cut problems (i.e., we want that there is no path of length at least ℓ \ell ℓ connecting s s s and t t t ) are W[1 ] -hard; however to our knowledge this is not known.
A Second Proof of W[1]-hardness that Works for All Variants
In this section we give a full proof of Theorem 5.2 that works for all variants of the problems P L E P ⋈ X \mathrm{PLEP}_{\bowtie}^{X} PLEP ⋈ X for ⋈ ∈ { ≤ , ≥ } \bowtie\in\{\leq,\geq\} ⋈∈ { ≤ , ≥ } and X ∈ { W a l k , P a t h } X \in\{\mathrm{Walk},\mathrm{Path}\} X ∈ { Walk , Path } , and that in addition shows hardness already for the case of acyclic probabilistic graphs. We focus first on the case of P L E P ≥ P a t h \mathrm{PLEP}_{\geq}^{\mathrm{Path}} PLEP ≥ Path and explain after that why the proof also works for the other variants. For any integer q ≥ 1 q \geq1 q ≥ 1 , we write [ q ] [q] [ q ] for the set { 1 , … , q } \{1,\ldots,q\} { 1 , … , q } .
The source of hardness will be the problem of counting the linear extensions of a partially ordered set (poset). Recall that a poset P = ( A , ≤ P ) \mathcal{P}=(A,\leq_{\mathcal{P}}) P = ( A , ≤ P ) is a set A A A together with a relation ≤ P ⊆ A 2 \leq_{\mathcal{P}}\subseteq A^2 ≤ P ⊆ A 2 that is reflexive, transitive and antisymmetric. For x , y ∈ A x,y\in A x , y ∈ A , we say that y y y covers x x x , written x ≺ P y x\prec_{\mathcal{P}} y x ≺ P y , if we have x ≠ y x\ne y x = y , we have x ≤ P y x\leq_{\mathcal{P}}y x ≤ P y , and for every z ∈ A z\in A z ∈ A such that x ≤ P z ≤ P y x\leq_{\mathcal{P}}z\leq_{\mathcal{P}}y x ≤ P z ≤ P y it holds that z = x z=x z = x or z = y z=y z = y . The cover graph of P \mathcal{P} P (also called the Hasse diagram) is the graph G P = ( A , ≺ P ) G_{\mathcal{P}}=(A,\prec_{\mathcal{P}}) G P = ( A , ≺ P ) , i.e., whose vertices are the elements of A A A , and which contains a directed edge x → y x\to y x → y whenever x ≺ P y x\prec_{\mathcal{P}}y x ≺ P y . A linear extension of P \mathcal{P} P is a permutation π : A → [ ∣ A ∣ ] \pi:A\to[|A|] π : A → [ ∣ A ∣ ] which ensures that, for every x , y ∈ A x,y\in A x , y ∈ A , if x ≤ P y x\leq_{\mathcal{P}}y x ≤ P y then π ( x ) ≤ π ( y ) \pi(x)\leq\pi(y) π ( x ) ≤ π ( y ) .
Every poset admits linear extensions, which can be computed in linear time using any topological sorting algorithm. By contrast, the authors of [24 ] show that the problem of counting the linear extensions of a (finite) poset P \mathcal{P} P is W[1 ] -hard under Turing reductions parameterised by the treewidth of G P G_{\mathcal{P}} G P , and those of [13 ] (cf. Section 1.1 and text before) actually notice that their proof also holds for pathwidth. So we will reduce from the following:
Theorem C.3 ([24 , 13 ] ). Counting the linear extensions of a finite poset is W[1 ] -hard (under Turing reductions) parameterised by the pathwidth of (the cover graph of) the poset.
We will reduce that problem to P L E P ≥ P a t h \mathrm{PLEP}_{\geq}^{\mathrm{Path}} PLEP ≥ Path , in two steps. First, we reduce to the problem of counting the number of order-preserving maps to a chain , as defined next. A q q q -order-preserving map from a poset P = ( A , ≤ P ) \mathcal{P}=(A,\leq_{\mathcal{P}}) P = ( A , ≤ P ) is a map f : A → [ q ] f:A\to[q] f : A → [ q ] which ensures that, for every x , y ∈ A x,y\in A x , y ∈ A , if x ≤ P y x\leq_{\mathcal{P}}y x ≤ P y then f ( x ) ≤ f ( y ) f(x)\leq f(y) f ( x ) ≤ f ( y ) . Notice that f ( x ) = f ( y ) f(x)=f(y) f ( x ) = f ( y ) is allowed; in fact, notice that the linear extensions of P \mathcal{P} P correspond exactly to the ∣ A ∣ |A| ∣ A ∣ -order-preserving maps of P \mathcal{P} P that are bijective. The problem of counting order-preserving maps for posets then takes as input a poset P \mathcal{P} P , an integer q ≥ 2 q\geq2 q ≥ 2 given in unary, and outputs the number of q q q -order-preserving maps of P \mathcal{P} P . We claim the following, which is the first step of the proof:
Proposition C.4. The problem of counting linear extensions of posets has an FPT (Turing) reduction, parameterised by the pathwidth of G P G_{\mathcal{P}} G P , to the problem of counting the number of order-preserving maps of posets.
Proof. For a poset P = ( A , ≤ P ) \mathcal{P}=(A,\leq_{\mathcal{P}}) P = ( A , ≤ P ) , let Ω P ( q ) \Omega_{\mathcal{P}}(q) Ω P ( q ) be the number of q q q -order-preserving maps of P \mathcal{P} P . It is known that Ω P ( q ) \Omega_{\mathcal{P}}(q) Ω P ( q ) is a polynomial of degree ∣ A ∣ |A| ∣ A ∣ in the variable q q q , and that its leading coefficient is equal to the number of linear extensions of P \mathcal{P} P divided by ∣ A ∣ ! |A|! ∣ A ∣ ! : see for instance [33 paragraph before Example 3.12.2] . Thus, using the problem of counting order-preserving maps as an oracle to compute Ω P ( q ) \Omega_{\mathcal{P}}(q) Ω P ( q ) on ∣ A ∣ + 1 |A|+1 ∣ A ∣ + 1 different values of q q q (which we write in unary), we can recover in polynomial time the number of linear extensions of P \mathcal{P} P (this is again inverting a Vandermonde matrix, or equivalently, performing Lagrange interpolation to compute the ∣ A ∣ + 1 |A|+1 ∣ A ∣ + 1 coefficients of the degree-∣ A ∣ |A| ∣ A ∣ polynomial from the evaluation in ∣ A ∣ + 1 |A|+1 ∣ A ∣ + 1 points). This is clearly a valid FPT reduction as the poset P \mathcal{P} P has not been modified.
Thus, all that is needed to show the W[1 ] -hardness of P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\geq} PLEP ≥ Path is the following:
Proposition C.5. The problem of counting the number of order-preserving maps of posets, parameterised by pathwidth of their cover graph, has an FPT (Turing) reduction to P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\geq} PLEP ≥ Path , parameterised by pathwidth, on acyclic probabilistic graphs.
Proof. Let P = ( A , ⪯ P ) \mathcal{P}=(A,\preceq_{\mathcal{P}}) P = ( A , ⪯ P ) be the input poset and q ≥ 2 q \geq2 q ≥ 2 be an integer given as input (in unary); our goal is to compute the number of q q q -order-preserving maps of P \mathcal{P} P . Let n : = ∣ A ∣ n := |A| n := ∣ A ∣ . Build a directed graph G = ( V , E ) G=(V,E) G = ( V , E ) as follows:
for every element x ∈ A x \in A x ∈ A , we have a vertex u x u_x u x and a vertex v x ∈ V v_x \in V v x ∈ V ;
for every x ∈ A x \in A x ∈ A , we have an edge ( u x , v x ) (u_x,v_x) ( u x , v x ) ;
for every x , y ∈ A x,y \in A x , y ∈ A such that x ≺ P y x \prec_{\mathcal{P}} y x ≺ P y , we have an edge ( u x , v y ) (u_x,v_y) ( u x , v y ) ;
we have s , t ∈ V s,t \in V s , t ∈ V for two fresh source and target vertices s s s and t t t ;
for every x ∈ A x \in A x ∈ A and every r ∈ [ q − 1 ] r \in[q-1] r ∈ [ q − 1 ] , we have a fresh path of length r r r from s s s to u x u_x u x ;
for every x ∈ A x \in A x ∈ A and every r ∈ [ q − 1 ] r \in[q-1] r ∈ [ q − 1 ] , we have a fresh path of length r r r from v x v_x v x to t t t ;
Notice that G G G is indeed a directed acyclic graph. We now let U U U be the set of edges containing the first edge of each path from Item 5, and the first edge of each path in Item 6; we call U U U the coding edges . We let D D D denote all other edges, and call them exogenous . This construction is illustrated in Figure 1 on a small poset with 3 elements. For x ∈ A x \in A x ∈ A , let U x U_x U x be the set of edges of U U U that are on the path from s s s to u x u_x u x or on the path from v x v_x v x to t t t that contain the x x x -related coding edges. Notice that U = ⋃ x ∈ A U x U=\bigcup_{x\in A}U_x U = ⋃ x ∈ A U x with the union being disjoint. It is not hard to check that the pathwidth of G G G is at most 2 k + 5 2k+5 2 k + 5 , for k k k the pathwidth of the cover graph of P \mathcal{P} P . Indeed, from a path decomposition of the cover graph of P \mathcal{P} P , we can simply replace each element x x x of P \mathcal{P} P by the two vertices u x u_x u x and v x v_x v x , add s s s and t t t to every bag, and insert one sequence of bags for each path of Item 5 and of Item 6 above.
We now use our oracle for P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\geq} PLEP ≥ Path , via Lemma C.1, to solve the generalised cardinality computation problem for the property P P P defined as follows: given a graph G = ( V , E ) G=(V,E) G = ( V , E ) , vertices s s s and t t t , the length q q q , and a subset S ⊆ E S \subseteq E S ⊆ E , the property P P P is satisfied if G [ S ] G[S] G [ S ] contains a path of length > q >q > q . Observe that the probabilistic computation problem for this property P P P is precisely our target problem P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\geq} PLEP ≥ Path . Now, consider the generalised cardinality computation problem with the set of exogenous edges T : = D T:=D T := D , and the target cardinality c : = n ( q − 1 ) c:=n(q-1) c := n ( q − 1 ) for the sets S S S . The oracle for the generalised cardinality computation problem thus allows us to compute the number ω ′ \omega' ω ′ of subsets S ⊆ U S\subseteq U S ⊆ U of cardinality n ( q − 1 ) n(q-1) n ( q − 1 ) such that G [ D ∪ S ] G[D\cup S] G [ D ∪ S ] contains a path from s s s to t t t of length > q >q > q . By changing variables and counting over the complements of S S S relative to U U U instead, this is equal to the number of subsets S ⊆ U S\subseteq U S ⊆ U of cardinality ∣ U ∣ − n ( q − 1 ) = 2 n ( q − 1 ) − n ( q − 1 ) = n ( q − 1 ) |U|-n(q-1)=2n(q-1)-n(q-1)=n(q-1) ∣ U ∣ − n ( q − 1 ) = 2 n ( q − 1 ) − n ( q − 1 ) = n ( q − 1 ) such that G [ D ∪ ( U ∖ S ) ] = G [ E ∖ S ] G[D\cup(U\setminus S)]=G[E\setminus S] G [ D ∪ ( U ∖ S )] = G [ E ∖ S ] contains a path from s s s to t t t of length > q >q > q . From this, we deduce the number ω : = ( 2 n ( q − 1 ) n ( q − 1 ) ) − ω ′ \omega:=\binom{2n(q-1)}{n(q-1)}-\omega' ω := ( n ( q − 1 ) 2 n ( q − 1 ) ) − ω ′ of subsets S ⊆ U S\subseteq U S ⊆ U of cardinality n ( q − 1 ) n(q-1) n ( q − 1 ) such that G [ E ∖ S ] G[E\setminus S] G [ E ∖ S ] does not contain a path from s s s to t t t of length > q >q > q . We now claim that ω \omega ω is equal to the number of q q q -order-preserving maps of P \mathcal{P} P , which would conclude the proof because we can then simply return ω \omega ω , and the overall reduction is indeed a valid FPT (Turing) reduction.
To prove this claim, we show that there is a bijection between the subsets S ⊆ U S\subseteq U S ⊆ U of size n ( q − 1 ) n(q-1) n ( q − 1 ) such that G [ E ∖ S ] G[E\setminus S] G [ E ∖ S ] contains no path from s s s to t t t of length > q >q > q , and the q q q -order-preserving maps of P \mathcal{P} P .
Let S S S be such a set. For x ∈ A x\in A x ∈ A , let a x a_x a x be one plus the length of the longest path from s s s to u x u_x u x in G [ E ∖ S ] G[E\setminus S] G [ E ∖ S ] if such a path exists, and 1 otherwise. Notice that a x a_x a x is in [ q ] [q] [ q ] . We will show that the function f S : A → [ q ] f_S:A\to[q] f S : A → [ q ] that associates x ∈ A x\in A x ∈ A to a x a_x a x is a q q q -order-preserving map. Let b x ′ b'_x b x ′ be one plus the length of the longest path from v x v_x v x to t t t in G [ E ∖ S ] G[E\setminus S] G [ E ∖ S ] if such a path exists, and 1 otherwise; and define b x = q + 1 − b x ′ b_x = q + 1 - b'_x b x = q + 1 − b x ′ . Thanks to the edges from Item 2, we have that a x + b x ′ ≤ q + 1 a_x + b'_x \leq q + 1 a x + b x ′ ≤ q + 1 (as otherwise we would have a path of length > q >q > q from s s s to t t t in G [ E ∖ S ] G[E\setminus S] G [ E ∖ S ] ), i.e., a x ≤ b x a_x \leq b_x a x ≤ b x . Furthermore, having a x + b x ′ ≤ q + 1 a_x + b'_x \leq q + 1 a x + b x ′ ≤ q + 1 implies that ∣ U x ∩ S ∣ ≥ q − 1 |U_x \cap S| \geq q - 1 ∣ U x ∩ S ∣ ≥ q − 1 : this is intuitively because we have paths of every possible length in [ q − 1 ] [q-1] [ q − 1 ] from s s s to u x u_x u x and likewise from v x v_x v x to t t t so that we must remove one edge each time we decrement the sum of the lengths of the longest remaining paths, so bringing the sum of lengths down from 2 ( q − 1 ) 2(q-1) 2 ( q − 1 ) to q − 1 q-1 q − 1 requires q − 1 q-1 q − 1 edge removals. Now, because U = ⋃ x ∈ A U x U = \bigcup_{x\in A} U_x U = ⋃ x ∈ A U x with the union being disjoint, and because ∣ S ∣ = n ( q − 1 ) |S| = n(q-1) ∣ S ∣ = n ( q − 1 ) , we must have in fact that ∣ U x ∩ S ∣ = q − 1 |U_x \cap S| = q - 1 ∣ U x ∩ S ∣ = q − 1 for each x ∈ A x \in A x ∈ A . This implies that we must have a x = b x a_x = b_x a x = b x for x ∈ A x \in A x ∈ A . Indeed, we know that a x ≤ b x a_x \leq b_x a x ≤ b x , and if we have a x < b x a_x < b_x a x < b x then we have a x + b x ′ < q + 1 a_x + b'_x < q+1 a x + b x ′ < q + 1 which by the decrement argument earlier would require > q − 1 >q-1 > q − 1 edge removals, exceeding our budget of ∣ U x ∩ S ∣ = q − 1 |U_x \cap S| = q-1 ∣ U x ∩ S ∣ = q − 1 for this x x x . Now, thanks to the edges of Item 3, for every x , y ∈ A x,y \in A x , y ∈ A with x ≺ P y x \prec_{\mathcal{P}} y x ≺ P y , we must also have that a x + b y ′ ≤ q + 1 a_x + b'_y \leq q+1 a x + b y ′ ≤ q + 1 , i.e., a x ≤ b y a_x \leq b_y a x ≤ b y , so a x ≤ a y a_x \leq a_y a x ≤ a y because we showed that b y = a y b_y = a_y b y = a y . We have established that f S f_S f S is order-preserving on the cover relation ≺ P \prec_{\mathcal{P}} ≺ P , which thanks to transitivity is sufficient to establish that we have f S ( x ) ≤ f S ( y ) f_S(x) \leq f_S(y) f S ( x ) ≤ f S ( y ) for all x , y ∈ A x,y \in A x , y ∈ A with x ⪯ P y x \preceq_{\mathcal{P}} y x ⪯ P y , e.g., by considering a chain x ≺ P z 1 ≺ P ⋯ ≺ P z k ≺ P y x \prec_{\mathcal{P}} z_1 \prec_{\mathcal{P}} \cdots\prec_{\mathcal{P}} z_k \prec_{\mathcal{P}} y x ≺ P z 1 ≺ P ⋯ ≺ P z k ≺ P y and combining the inequalities. Thus, we have indeed shown that the function f S f_S f S is a q q q -order-preserving map.
Conversely, if f : A → [ q ] f:A\to[q] f : A → [ q ] is a q q q -order-preserving map, let us define S f ⊆ U S_f\subseteq U S f ⊆ U as follows. For x ∈ A x\in A x ∈ A , we put in S f S_f S f all edges of U x U_x U x that lie on a path from s s s to u x u_x u x of length at least f ( x ) f(x) f ( x ) (there are q − f ( x ) q-f(x) q − f ( x ) such edges), as well as all those that lie on a path from v x v_x v x to t t t of length at least q − f ( x ) + 1 q-f(x)+1 q − f ( x ) + 1 (there are f ( x ) − 1 f(x)-1 f ( x ) − 1 such edges). It is clear then that ∣ S f ∣ = n ( q − 1 ) |S_f|=n(q-1) ∣ S f ∣ = n ( q − 1 ) , so we only need to argue why it is the case that G [ E ∖ S f ] G[E\setminus S_f] G [ E ∖ S f ] contains no path of length > q >q > q from s s s to t t t . Let p p p be a longest path in G [ E ∖ S f ] G[E\setminus S_f] G [ E ∖ S f ] from s s s to t t t , if it exists (otherwise there is nothing to show). By construction of G G G , paths from s s s to t t t must either go through an edge of the form ( u x , v y ) (u_x,v_y) ( u x , v y ) with x ≠ y x\neq y x = y (case 1), or through an edge of the form ( u x , v x ) (u_x,v_x) ( u x , v x ) (case 2). For case 1, by definition of S f S_f S f and by construction of G G G , we have that 1 < f ( x ) 1<f(x) 1 < f ( x ) and f ( y ) < q f(y)<q f ( y ) < q , and we see that the part of p p p between s s s and u x u_x u x has length f ( x ) − 1 f(x)-1 f ( x ) − 1 and that the part between v y v_y v y and t t t has length q − f ( y ) q-f(y) q − f ( y ) , so that the total length of the path is f ( x ) − 1 + q − f ( y ) + 1 = q + f ( x ) − f ( y ) f(x)-1+q-f(y)+1=q+f(x)-f(y) f ( x ) − 1 + q − f ( y ) + 1 = q + f ( x ) − f ( y ) . But f ( x ) ≤ f ( y ) f(x)\leq f(y) f ( x ) ≤ f ( y ) since f f f is order-preserving, hence the length of p p p is at most q q q . For case 2, if a path uses an edge of the form ( u x , v x ) (u_x,v_x) ( u x , v x ) , then we have 1 < f ( x ) < q 1<f(x)<q 1 < f ( x ) < q and the length of the path is exactly q q q . Therefore, G [ E ∖ S f ] G[E\setminus S_f] G [ E ∖ S f ] indeed contains no path of length > q >q > q from s s s to t t t .
The last two paragraphs establish the existence of the bijection that we claimed, so this concludes the proof.
We now conclude the proof of Theorem 5.2. Our proof given so far works for the variants P L E P ≤ W a l k \mathrm{PLEP}_{\leq}^{\mathrm{Walk}} PLEP ≤ Walk and equivalently P L E P ≤ P a t h \mathrm{PLEP}_{\leq}^{\mathrm{Path}} PLEP ≤ Path because the constructed graph is acyclic. Namely, the W [ 1 ] \mathrm{W}[1] W [ 1 ] -hardness follows directly from Proposition C.5 together with Proposition C.4. We now explain why this reduction can be adapted to the ≤ \leq ≤ variants of P L E P × \mathrm{PLEP}^{\times} PLEP × , i.e., to P L E P ≤ P a t h \mathrm{PLEP}_{\leq}^{\mathrm{Path}} PLEP ≤ Path (or P L E P ≤ W a l k \mathrm{PLEP}_{\leq}^{\mathrm{Walk}} PLEP ≤ Walk which is the same problem). We use oracle calls to P L E P ≤ P a t h \mathrm{PLEP}_{\leq}^{\mathrm{Path}} PLEP ≤ Path to compute the number of subsets S ⊆ U S\subseteq U S ⊆ U of size n ( q − 1 ) n(q-1) n ( q − 1 ) such that G [ E ∖ S ] G[E\setminus S] G [ E ∖ S ] contains no path of length < q + 2 <q+2 < q + 2 . It is then routine to check that the rest of the proof also adapts. Namely, we have a bijection between the subsets S ⊆ U S\subseteq U S ⊆ U of size n ( q − 1 ) n(q-1) n ( q − 1 ) such that G [ E ∖ S ] G[E\setminus S] G [ E ∖ S ] contains no path from s s s to t t t of length < q + 2 <q+2 < q + 2 , and the q q q -order-preserving maps of P \mathcal{P} P . This is shown in the forward direction by defining, for each set S ⊆ U S\subseteq U S ⊆ U , the value a x a_x a x is the length of the shortest path from s s s to u x u_x u x if such a path exists and q q q otherwise, and similarly for b x ′ b'_x b x ′ . We deduce that a x + b x ′ ≥ q + 1 a_x+b'_x\geq q+1 a x + b x ′ ≥ q + 1 so a x > b x a_x>b_x a x > b x , and the disjoint union argument with the dual observation that incrementing the length of shortest paths requires one edge removal per increment implies that a x = b x a_x=b_x a x = b x for each x x x . The rest of the proof of the forward direction follows by defining f S ( x ) : = q − a x + 1 f_S(x):=q-a_x+1 f S ( x ) := q − a x + 1 , i.e., whenever x ≺ P y x\prec_{\mathcal{P}}y x ≺ P y we must have a x ≥ a y a_x\geq a_y a x ≥ a y so f S f_S f S as we now define it is an order-preserving map. Likewise, the proof of the backward direction follows, except that we now consider shortest paths and that we construct S f S_f S f from f f f by deleting the edges of the q − f ( x ) q-f(x) q − f ( x ) shortest paths from s s s to u x u_x u x and of the f ( x ) − 1 f(x)-1 f ( x ) − 1 shortest paths from v x v_x v x to t t t . This concludes the proof of Theorem 5.2.
Proofs for At-Most Length Variants
In this section we first prove Claim 5.3 used for showing the tractability of PLEP≤ P a t h _{\leq}^{\mathrm{Path}} ≤ Path for probabilistic graphs of bounded treewidth (refer Section 5.1), by providing an algorithm that computes the shortest path length function for each node in a bottom-up manner (Algorithm 3 ). The computation is fairly simple when the node under consideration is an Introduce Vertex node, a Forget Vertex node, or an Introduce Edge node. The case of a Join node is more interesting, as given a realisation H b H_b H b of a Join node b b b with children b 1 b_1 b 1 and b 2 b_2 b 2 which can be obtained by picking independently realisations H b 1 H_{b_1} H b 1 and H b 2 H_{b_2} H b 2 of G b 1 \mathcal{G}_{b_1} G b 1 and G b 2 \mathcal{G}_{b_2} G b 2 , we need additional machinery to determine the shortest path length function S P L H b \mathrm{SPL}_{H_b} SPL H b from the shortest path length functions S P L H b 1 \mathrm{SPL}_{H_{b_1}} SPL H b 1 , S P L H b 2 \mathrm{SPL}_{H_{b_2}} SPL H b 2 . In particular we shall use the fact that it is possible to determine, in a weighted directed graph, the length of the shortest path from a given vertex u u u to another v v v . To that effect, we define the All Pairs Shortest Path Problem .
All Pairs Shortest Path Problem. In this problem, a weighted directed graph G = ( V , δ : V × V → N ∪ { ⊥ } ) G=(V,\delta:V\times V\to\mathbb{N}\cup\{\bot\}) G = ( V , δ : V × V → N ∪ { ⊥ }) is given and we must determine the length of the shortest path from vertex u u u to vertex v v v for all such ( u , v ) (u,v) ( u , v ) pairs of vertices, where ⊥ \bot ⊥ denotes that the edge does not exist, and where the values returned can be ⊥ \bot ⊥ when no path exists from one vertex to another. (In other words, ⊥ \bot ⊥ behaves like + ∞ +\infty + ∞ , but we do not use + ∞ +\infty + ∞ because it is used with a different semantics in Section 5.2.) Here the length of the path refers to the sum of weights of its constituent edges. The problem is known to be solvable in polynomial time (O ( ∣ V ∣ 3 ) O(|V|^3) O ( ∣ V ∣ 3 ) ) using algorithms such as the Floyd-Warshall algorithm. From now on we denote by ALG–APSP an algorithm that solves in polynomial time the following All Pairs Shortest Path Problem:
caption:
:::
Next, we define a change-over vertex of a path P P P from a vertex s s s to another vertex t t t .
Definition C.6. Let G 1 = ( V 1 , E 1 ) G_1=(V_1,E_1) G 1 = ( V 1 , E 1 ) and G 2 = ( V 2 , E 2 ) G_2=(V_2,E_2) G 2 = ( V 2 , E 2 ) be two graphs, with E 1 ∩ E 2 = ∅ E_1\cap E_2=\varnothing E 1 ∩ E 2 = ∅ and possibly some vertices in common, and let G = ( V 1 ∪ V 2 , E 1 ∪ ˙ E 2 ) G=(V_1\cup V_2,E_1\mathbin{\dot\cup}E_2) G = ( V 1 ∪ V 2 , E 1 ∪ ˙ E 2 ) be the union of these two graphs. Let P P P be any path from s s s to t t t in G G G . A change-over vertex of P P P is a vertex v v v satisfying either of the following properties:
v v v is an endpoint of P P P , namely v = s v=s v = s or v = t v=t v = t .
Otherwise, letting v 1 v_1 v 1 and v 2 v_2 v 2 be the vertices immediately before and after v v v , then the edge joining v 1 v_1 v 1 and v v v belongs to E 1 E_1 E 1 and the edge joining v v v and v 2 v_2 v 2 belongs to E 2 E_2 E 2 , or vice versa.
Now, we prove the key claim that makes it possible to compute the shortest path length function for the Join node in Algorithm 3 . This essentially depends on the fact that bags of tree decomposition are separators.
Claim C.7. Let G = ( V , E , π ) \mathcal{G}=(V,E,\pi) G = ( V , E , π ) be a probabilistic graph with underlying non-probabilistic graph G = ( V , E ) G=(V,E) G = ( V , E ) , let S \mathcal{S} S be a nice tree decomposition of G \mathcal{G} G , and let b b b be a Join node with children b 1 b_1 b 1 and b 2 b_2 b 2 . Note that S b = S b 1 = S b 2 S_b=S_{b_1}=S_{b_2} S b = S b 1 = S b 2 . Recall that we denote by G b 1 \mathcal{G}_{b_1} G b 1 and G b 2 \mathcal{G}_{b_2} G b 2 the probabilistic subgraphs induced by the subtrees rooted at b 1 b_1 b 1 and b 2 b_2 b 2 respectively. Let G 1 = ( V 1 , E 1 ) G_1=(V_1,E_1) G 1 = ( V 1 , E 1 ) and G 2 = ( V 2 , E 2 ) G_2=(V_2,E_2) G 2 = ( V 2 , E 2 ) be realisations of G b 1 \mathcal{G}_{b_1} G b 1 and G b 2 \mathcal{G}_{b_2} G b 2 , respectively. Define H b = ( V 1 ∪ V 2 , E 1 ∪ E 2 ) H_b=(V_1\cup V_2,E_1\cup E_2) H b = ( V 1 ∪ V 2 , E 1 ∪ E 2 ) (we note that H b H_b H b is a graph formed by taking the union of G 1 G_1 G 1 and G 2 G_2 G 2 . Consider any path P P P in H b H_b H b from a vertex s s s to a vertex t t t where s , t ∈ S b s,t\in S_b s , t ∈ S b . Then:
Any change-over vertex belonging to the path P P P must necessarily belong to S b S_b S b .
Define H ( S b , δ ) H(S_b,\delta) H ( S b , δ ) to be the weighted directed graph with set of vertices S b S_b S b and with weights δ ( v i , v j ) = min ( f 1 ( v i , v j ) , f 2 ( v i , v j ) ) \delta(v_i,v_j)=\min(f_1(v_i,v_j),f_2(v_i,v_j)) δ ( v i , v j ) = min ( f 1 ( v i , v j ) , f 2 ( v i , v j )) for all v i , v j ∈ S b v_i,v_j\in S_b v i , v j ∈ S b , where f 1 ( v i , v j ) : = S P L G 1 , S b ( v i , v j ) f_1(v_i,v_j):=\mathrm{SPL}_{G_1,S_b}(v_i,v_j) f 1 ( v i , v j ) := SPL G 1 , S b ( v i , v j ) and f 2 ( v i , v j ) : = S P L G 2 , S b ( v i , v j ) f_2(v_i,v_j):=\mathrm{SPL}_{G_2,S_b}(v_i,v_j) f 2 ( v i , v j ) := SPL G 2 , S b ( v i , v j ) , where min \min min ignores ⊥ \bot ⊥ in its arguments except when both arguments
are ⊥ \perp ⊥ in which case it evaluates to ⊥ \perp ⊥ . Then we have SPL H b , S b = f \operatorname{SPL}_{H_b,S_b}=f SPL H b , S b = f , where f f f is given as follows: For every v i , v j ∈ S b v_i,v_j\in S_b v i , v j ∈ S b , f ( v i , v j ) f(v_i,v_j) f ( v i , v j ) equals the length of a shortest path from v i v_i v i to v j v_j v j in the weighted directed graph H ( S b , δ ) H(S_b,\delta) H ( S b , δ ) .
Proof. We first prove Item 1. Let w w w be a change-over vertex. If w w w is s s s or t t t then w ∈ S b w\in S_b w ∈ S b by hypothesis. Otherwise, there are w ′ , w ′ ′ ∈ V w',w''\in V w ′ , w ′′ ∈ V with ( w ′ , w ) (w',w) ( w ′ , w ) an edge of G 1 G_1 G 1 and ( w , w ′ ′ ) (w,w'') ( w , w ′′ ) an edge of G 2 G_2 G 2 . By definition of G 1 G_1 G 1 and G 2 G_2 G 2 , this implies that w w w occurs both in the subtree rooted at b 1 b_1 b 1 and in the subtree rooted at b 2 b_2 b 2 , hence by the connectedness property of tree decompositions w w w must also occur in S b S_b S b .
We now prove Item 2. First, we prove that, for any s , t ∈ S b s,t\in S_b s , t ∈ S b , the shortest path from s s s to t t t in H ( S b , δ ) H(S_b,\delta) H ( S b , δ ) is no longer than the shortest path from s s s to t t t in H b H_b H b . Let P P P be any shortest path from s s s to t t t in H b H_b H b . Let the change-over vertices appearing in P P P , in that order, be u 1 , u 2 , … , u k u_1,u_2,\ldots,u_k u 1 , u 2 , … , u k (s = u 1 , t = u k s=u_1,t=u_k s = u 1 , t = u k ); by Item 1 we know that they are all in S b S_b S b . Moreover by the definition of change-over vertex, the edges appearing between any two consecutive change-over vertices u i u_i u i and u i + 1 u_{i+1} u i + 1 for i ∈ [ 1 , 2 , 3 , … , k − 1 ] i\in[1,2,3,\ldots,k-1] i ∈ [ 1 , 2 , 3 , … , k − 1 ] lie exclusively in either E 1 E_1 E 1 or E 2 E_2 E 2 . But the shortest path from u i u_i u i to u i + 1 u_{i+1} u i + 1 lying exclusively in G 1 G_1 G 1 has length f 1 ( u i , u i + 1 ) f_1(u_i,u_{i+1}) f 1 ( u i , u i + 1 ) whereas the shortest path lying exclusively in G 2 G_2 G 2 has length f 2 ( u i , u i + 1 ) f_2(u_i,u_{i+1}) f 2 ( u i , u i + 1 ) , therefore if we consider the shorter of these two paths then it has length min ( f 1 ( u i , u i + 1 ) , f 2 ( u i , u i + 1 ) ) \min(f_1(u_i,u_{i+1}),f_2(u_i,u_{i+1})) min ( f 1 ( u i , u i + 1 ) , f 2 ( u i , u i + 1 )) and is shorter than any other path lying exclusively in G 1 G_1 G 1 or G 2 G_2 G 2 . Therefore the length of the section of the path P P P between u i , u i + 1 u_i,u_{i+1} u i , u i + 1 must be equal to min ( f 1 ( u i , u i + 1 ) , f 2 ( u i , u i + 1 ) ) \min(f_1(u_i,u_{i+1}),f_2(u_i,u_{i+1})) min ( f 1 ( u i , u i + 1 ) , f 2 ( u i , u i + 1 )) (otherwise P P P would not be a shortest path from s s s to t t t ). The total length of the path P P P is therefore ∑ i = 1 k − 1 min ( f 1 ( u i , u i + 1 ) , f 2 ( u i , u i + 1 ) ) \sum_{i=1}^{k-1}\min(f_1(u_i,u_{i+1}),f_2(u_i,u_{i+1})) ∑ i = 1 k − 1 min ( f 1 ( u i , u i + 1 ) , f 2 ( u i , u i + 1 )) . Now consider the path s = u 1 , u 2 , … , u k = t s=u_1,u_2,\ldots,u_k=t s = u 1 , u 2 , … , u k = t in H ( S b , δ ) H(S_b,\delta) H ( S b , δ ) . Observe that the length of this path is ∑ i = 1 k − 1 δ ( u i , u i + 1 ) \sum_{i=1}^{k-1}\delta(u_i,u_{i+1}) ∑ i = 1 k − 1 δ ( u i , u i + 1 ) which is precisely the length of P P P , i.e., the length of any shortest path from s s s to t t t in H b H_b H b . This establishes that, indeed, the shortest path from s s s to t t t in H ( S b , δ ) H(S_b,\delta) H ( S b , δ ) is no longer than the shortest path from s s s to t t t in H b H_b H b .
Next we show that the path u 1 , u 2 , … , u k u_1,u_2,\ldots,u_k u 1 , u 2 , … , u k is indeed the shortest path in H ( S b , δ ) H(S_b,\delta) H ( S b , δ ) . Suppose by contradiction that there is a shorter path v 1 , v 2 , … , v l v_1,v_2,\ldots,v_l v 1 , v 2 , … , v l where v 1 = s v_1=s v 1 = s , v l = t v_l=t v l = t and ∑ j = 1 l − 1 δ ( v j , v j + 1 ) < ∑ i = 1 k − 1 δ ( u i , u i + 1 ) \sum_{j=1}^{l-1}\delta(v_j,v_{j+1})<\sum_{i=1}^{k-1}\delta(u_i,u_{i+1}) ∑ j = 1 l − 1 δ ( v j , v j + 1 ) < ∑ i = 1 k − 1 δ ( u i , u i + 1 ) . Then we replace every edge ( v i , v i + 1 ) (v_i,v_{i+1}) ( v i , v i + 1 ) of weight δ ( v i , v i + 1 ) \delta(v_i,v_{i+1}) δ ( v i , v i + 1 ) with a path of equal length in H b H_b H b : if δ ( v i , v i + 1 ) = f 1 ( v i , v i + 1 ) \delta(v_i,v_{i+1})=f_1(v_i,v_{i+1}) δ ( v i , v i + 1 ) = f 1 ( v i , v i + 1 ) then replace the edge with a shortest path from v i v_i v i to v i + 1 v_{i+1} v i + 1 in G 1 G_1 G 1 ; otherwise, if δ ( v i , v i + 1 ) = f 2 ( v i , v i + 1 ) \delta(v_i,v_{i+1})=f_2(v_i,v_{i+1}) δ ( v i , v i + 1 ) = f 2 ( v i , v i + 1 ) , then replace it with a shortest path from v i v_i v i to v i + 1 v_{i+1} v i + 1 in G 2 G_2 G 2 . Thus, we now obtain a path from s s s to t t t in H b H_b H b with length ∑ i = 1 l − 1 δ ( v i , v i + 1 ) \sum_{i=1}^{l-1}\delta(v_i,v_{i+1}) ∑ i = 1 l − 1 δ ( v i , v i + 1 ) . Further by assumption ∑ i = 1 l − 1 δ ( v i , v i + 1 ) < ∑ j = 1 k − 1 δ ( u j , u j + 1 ) \sum_{i=1}^{l-1}\delta(v_i,v_{i+1})<\sum_{j=1}^{k-1}\delta(u_j,u_{j+1}) ∑ i = 1 l − 1 δ ( v i , v i + 1 ) < ∑ j = 1 k − 1 δ ( u j , u j + 1 ) . However, ∑ j = 1 k − 1 δ ( u j , u j + 1 ) \sum_{j=1}^{k-1}\delta(u_j,u_{j+1}) ∑ j = 1 k − 1 δ ( u j , u j + 1 ) is the length of P P P , a shortest s s s -t t t path in H b H_b H b . Thus, we arrive at a contradiction. Hence, u 1 , u 2 , … , u k u_1,u_2,\ldots,u_k u 1 , u 2 , … , u k is indeed the shortest path from s s s to t t t in H ( S b , δ ) H(S_b,\delta) H ( S b , δ ) , and its length is the same as that of shortest path from s s s to t t t in H b H_b H b (= ∑ i = 1 k − 1 δ ( u i , u i + 1 ) =\sum_{i=1}^{k-1}\delta(u_i,u_{i+1}) = ∑ i = 1 k − 1 δ ( u i , u i + 1 ) ), thus proving the claim. ◂
Having established Claim C.7, we are now in a position to prove Claim 5.3, whose statement we recall here:
Claim 5.3. We can compute in XP parameterised by the treewidth of G \mathcal{G} G , for each bag S b S_b S b of S \mathcal{S} S , a table T b T_b T b indexed with all possible functions f : S b × S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f:S_b\times S_b\to\{0,1,\ldots,|V|-1\}\cup\{\perp\} f : S b × S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } such that T b [ f ] T_b[f] T b [ f ] equals the probability that in a random realisation H b H_b H b of G b \mathcal{G}_b G b , the function SPL H b , S b \operatorname{SPL}_{H_b,S_b} SPL H b , S b is equal to f f f .
Proof. We prove that this is what Algorithm 3 does, by structural induction on the nice tree decomposition. Clearly for a leaf node, the claim holds, since leaf nodes contain no vertices and the only function describing the shortest distance over the induced empty subgraph is the empty function with probability one, which is what our algorithm assigns. Therefore the base case holds. Assume that the claim holds for the children of b b b . We now show that it holds for b b b as well:
Case 1: b b b is a Forget Vertex node Note that our definition of the subgraph induced at a node b b b covers all the edges introduced until that point and all the vertices (in the bag or any of its descendants). Hence, let the child of b b b be b ′ b' b ′ ; then G b = G b ′ \mathcal{G}_b=\mathcal{G}_{b'} G b = G b ′ . Therefore for any realisation H H H of G b ′ \mathcal{G}_{b'} G b ′ such that SPL H , S b ′ \operatorname{SPL}_{H,S_{b'}} SPL H , S b ′ is given by f f f , we can map it to the same realisation of G b \mathcal{G}_b G b occurring with the same probability, the shortest path length function f ′ = SPL H , S b f'=\operatorname{SPL}_{H,S_b} f ′ = SPL H , S b now being given by the restriction of f f f to S b × S b S_b\times S_b S b × S b . Therefore the correctness of T b T_b T b follows directly from the correctness of T b ′ T_{b'} T b ′ obtained by induction hypothesis. Case 2: b b b is an Introduce Vertex node. Nodes of this kind do not introduce any edges, and they only add an isolated vertex to the associated subgraph: they also have precisely one child. The possible realisations of G b \mathcal{G}_b G b are thus in bijection with those of G b \mathcal{G}_b G b , where the bijection adds the single isolated vertex v 0 v_0 v 0 . Hence, the distribution on the shortest path length functions of the new node is obtained by considering all the outcomes at the child bag (where the distribution of the shortest path length function was correctly computed by induction hypothesis), and extending each such function to say that there is a path of length 0 0 0 from v 0 v_0 v 0 to itself, no path from v 0 v_0 v 0 to any other vertex or to v 0 v_0 v 0 from any other vertex, and that the shortest path length among other vertices is unchanged. The correctness of T b T_b T b again follows directly from that of T b ′ T_{b'} T b ′ obtained by induction hypothesis.
Case 3: b b b is a Join node. Let b b b be a Join node with children b 1 b_1 b 1 and b 2 b_2 b 2 . Consider realisations of G b 1 \mathcal{G}_{b_1} G b 1 and G b 2 \mathcal{G}_{b_2} G b 2 , say G 1 = ( V 1 , E 1 ) G_1 = (V_1, E_1) G 1 = ( V 1 , E 1 ) and G 2 = ( V 2 , E 2 ) G_2 = (V_2, E_2) G 2 = ( V 2 , E 2 ) respectively, such that the functions f 1 = S P L G 1 , S b 1 f_1 = \mathrm{SPL}_{G_1,S_{b_1}} f 1 = SPL G 1 , S b 1 and f 2 = S P L G 2 , S b 2 f_2 = \mathrm{SPL}_{G_2,S_{b_2}} f 2 = SPL G 2 , S b 2 are known. Consider the union of G 1 G_1 G 1 and G 2 G_2 G 2 which we define by H b = ( V 1 ∪ V 2 , E 1 ∪ E 2 ) H_b = (V_1 \cup V_2, E_1 \cup E_2) H b = ( V 1 ∪ V 2 , E 1 ∪ E 2 ) . Now, note that H b = ( V 1 ∪ V 2 , E 1 ∪ E 2 ) H_b = (V_1 \cup V_2, E_1 \cup E_2) H b = ( V 1 ∪ V 2 , E 1 ∪ E 2 ) is a realisation of G b \mathcal{G}_b G b , the probabilistic graph associated with the node b b b . By Claim C.7, we know that S P L H b , S b \mathrm{SPL}_{H_b,S_b} SPL H b , S b is given by the function f f f where for all u , v ∈ S b u,v \in S_b u , v ∈ S b , the value f ( u , v ) f(u,v) f ( u , v ) equals the length of the shortest path from u u u to v v v in the weighted graph H ( S b , δ ) H(S_b,\delta) H ( S b , δ ) with weight function δ ( u , v ) = min ( f 1 ( u , v ) , f 2 ( u , v ) ) \delta(u,v) = \min(f_1(u,v),f_2(u,v)) δ ( u , v ) = min ( f 1 ( u , v ) , f 2 ( u , v )) , and this holds for every realisation. Thus we can map pairs of realisations of G b 1 \mathcal{G}_{b_1} G b 1 and G b 2 \mathcal{G}_{b_2} G b 2 to realisations of G b \mathcal{G}_b G b , with the shortest path function of the realisation of G b \mathcal{G}_b G b being determined from the shortest path functions of G b 1 \mathcal{G}_{b_1} G b 1 and G b 2 \mathcal{G}_{b_2} G b 2 . The resulting shortest path function is computed by Algorithm 4 as prescribed by Claim C.7.
Case 4: b b b is an Introduce Edge node Algorithm 3 treats the addition of the new edge from u 0 u_0 u 0 to v 0 v_0 v 0 as taking a union of the graph under consideration with another graph with a single edge from u 0 u_0 u 0 to v 0 v_0 v 0 and all other vertices isolated. For the latter graph, the probability distribution over shortest path length functions is trivially known and then we use Algorithm 4 like for the case of a Join node.
Proofs for At-Least Length Simple Path Variants
Having shown the correctness of Claim 5.3, we now turn to the proof of Claim 5.6, which was established in Section 5.3 for showing the tractability of P L E P ≥ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\geq} PLEP ≥ Path in probabilistic graphs of bounded treewidth. Like in the case of P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\leq} PLEP ≤ Path we provide an algorithm (Algorithm 5) which computes, for every bag S b S_b S b in the tree decomposition, the probability distribution over the longest disjoint path length functions of S b S_b S b in G b \mathcal{G}_b G b . In other words, it computes, for every f : C P S P S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f : \mathrm{CPSP}_{S_b} \to\{0,1,\ldots,|V|-1\} \cup\{\bot\} f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , the probability that for a random realisation H H H of G b \mathcal{G}_b G b , we have f = L D P H , S b f = \mathrm{LDP}_{H,S_b} f = LDP H , S b . Further, like in the case of P L E P ≤ P a t h \mathrm{PLEP}^{\mathrm{Path}}_{\leq} PLEP ≤ Path , the most interesting case of Algorithm 5 is that of the Join node for which it uses the notion of an extension of a candidate path set projection Π \Pi Π , which we define next.
Definition C.8. Let A A A be a finite set of vertices. Consider any Π ∈ C P S P A \Pi\in\mathrm{CPSP}_A Π ∈ CPSP A , where C P S P A \mathrm{CPSP}_A CPSP A is the set of candidate path set projections of A A A (recall Definition 5.4). Let Π = { ( v 11 , v 12 , … , v 1 k 1 ) , ( v 21 , v 22 , … , v 2 k 2 ) , … , ( v λ 1 , v λ 2 , … , v λ k λ ) } \Pi= \{(v_{11},v_{12},\ldots,v_{1k_1),(v_{21},v_{22},\ldots,v_{2k_2),\ldots,(v_{\lambda1},v_{\lambda2},\ldots,v_{\lambda k_\lambda})\}}} Π = {( v 11 , v 12 , … , v 1 k 1 ) , ( v 21 , v 22 , … , v 2 k 2 ) , … , ( v λ 1 , v λ 2 , … , v λ k λ )} , thus Π \Pi Π is a collection of λ \lambda λ disjoint tuples. Let Π ′ \Pi' Π ′ be a set such that Π ′ \Pi' Π ′ satisfies the following property:
For each non-singleton tuple ( v 1 , v 2 , … , v k ) ∈ Π (v_1,v_2,\ldots,v_k) \in\Pi ( v 1 , v 2 , … , v k ) ∈ Π , the set Π ′ \Pi' Π ′ contains a collection of tuples formed by partitioning the index set [ k ] [k] [ k ] into consecutive intervals and restricting ( v 1 , v 2 , … , v k ) ∈ Π (v_1,v_2,\ldots,v_k) \in\Pi ( v 1 , v 2 , … , v k ) ∈ Π to each tuple, with the endpoints overlapping.
More formally, we keep each singleton tuple as-is, and we replace every non-singleton tuple ( v 1 , v 2 , … , v k ) (v_1,v_2,\ldots,v_k) ( v 1 , v 2 , … , v k ) by a finite sequence of tuples ( v ( 1 ) , v ( 2 ) , … , v ( m ) ) (\mathbf{v}^{(1)},\mathbf{v}^{(2)},\ldots,\mathbf{v}^{(m)}) ( v ( 1 ) , v ( 2 ) , … , v ( m ) ) for which there exist indices
1 = a 1 < b 1 = a 2 < b 2 = a 3 < ⋯ < b m − 1 = a m < b m = k 1 = a_1 < b_1 = a_2 < b_2 = a_3 < \cdots< b_{m-1} = a_m < b_m = k 1 = a 1 < b 1 = a 2 < b 2 = a 3 < ⋯ < b m − 1 = a m < b m = k such that
v ( j ) = ( v a j , v a j + 1 , … , v b j ) for all j = 1 , … , m . \mathbf{v}^{(j)} = (v_{a_j},v_{a_j+1},\ldots,v_{b_j}) \quad\text{for all } j = 1,\ldots,m. v ( j ) = ( v a j , v a j + 1 , … , v b j ) for all j = 1 , … , m .
Algorithm 3 DPComputationPLEP P a t h ( G = ( V , E , π ) , S ) \operatorname{DPComputationPLEP}^{\mathrm{Path}}(G=(V,E,\pi),\mathcal{S}) DPComputationPLEP Path ( G = ( V , E , π ) , S ) : Compute the probability distribution on the shortest path length function along a tree decomposition
Input: A probabilistic graph G = ( V , E , π : E → [ 0 , 1 ] ) G=(V,E,\pi:E\to[0,1]) G = ( V , E , π : E → [ 0 , 1 ]) of treewidth k k k and a nice tree decomposition S \mathcal{S} S with root b r o o t b_{\mathrm{root}} b root
Output: A table T T T indexed with all possible functions S b r o o t × S b r o o t → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } S_{b_{\mathrm{root}}}\times S_{b_{\mathrm{root}}}\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} S b root × S b root → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , such that T [ f ] T[f] T [ f ] is the probability that for any pair of vertices ( u , v ) (u,v) ( u , v ) in S b r o o t × S b r o o t S_{b_{\mathrm{root}}}\times S_{b_{\mathrm{root}}} S b root × S b root the length of the shortest path from u u u to v v v is f ( u , v ) f(u,v) f ( u , v ) (with ⊥ \bot ⊥ denoting that no such path exists).
Function TreeDP ( b ) \operatorname{TreeDP}(b) TreeDP ( b ) :
For each f : S b × S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f:S_b\times S_b\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} f : S b × S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , set T b [ f ] ← 0 T_b[f]\gets0 T b [ f ] ← 0
if b b b is a Leaf node then
T b [ empty function ] ← 1 T_b[\text{empty function}]\gets1 T b [ empty function ] ← 1
return T b T_b T b
else if b b b is a Forget Vertex node with child b ′ b' b ′ then
T b ′ ← TreeDP ( b ′ ) T_{b'}\gets\operatorname{TreeDP}(b') T b ′ ← TreeDP ( b ′ )
foreach f ′ : S b ′ × S b ′ → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f':S_{b'}\times S_{b'}\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} f ′ : S b ′ × S b ′ → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } do
Let f f f be the restriction of f ′ f' f ′ to S b × S b S_b\times S_b S b × S b
T b [ f ] ← T b [ f ] + T b ′ [ f ′ ] T_b[f]\gets T_b[f]+T_{b'}[f'] T b [ f ] ← T b [ f ] + T b ′ [ f ′ ]
return T b T_b T b
else if b b b is an Introduce Vertex node with child b ′ b' b ′ introducing vertex v 0 v_0 v 0 then
T b ′ ← TreeDP ( b ′ ) T_{b'}\gets\operatorname{TreeDP}(b') T b ′ ← TreeDP ( b ′ )
foreach f ′ : S b ′ × S b ′ → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f':S_{b'}\times S_{b'}\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} f ′ : S b ′ × S b ′ → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } do
Define f f f by
f ( u , v ) = { f ′ ( u , v ) if u ≠ v 0 and v ≠ v 0 , 0 if u = v 0 and v = v 0 , ⊥ otherwise f(u,v)=
\begin{cases}
f'(u,v) & \text{if }u\ne v_0\text{ and }v\ne v_0,\\
0 & \text{if }u=v_0\text{ and }v=v_0,\\
\bot& \text{otherwise}
\end{cases} f ( u , v ) = ⎩ ⎨ ⎧ f ′ ( u , v ) 0 ⊥ if u = v 0 and v = v 0 , if u = v 0 and v = v 0 , otherwise T b [ f ] ← T b [ f ] + T b ′ [ f ′ ] T_b[f]\gets T_b[f]+T_{b'}[f'] T b [ f ] ← T b [ f ] + T b ′ [ f ′ ]
return T b T_b T b
else if b b b is a Join node with children b 1 , b 2 b_1,b_2 b 1 , b 2 then
T b 1 ← TreeDP ( b 1 ) T_{b_1}\gets\operatorname{TreeDP}(b_1) T b 1 ← TreeDP ( b 1 )
T b 2 ← TreeDP ( b 2 ) T_{b_2}\gets\operatorname{TreeDP}(b_2) T b 2 ← TreeDP ( b 2 )
T b ← JoinComputationPLEP P a t h ( T b 1 , T b 2 , S b ) T_b\gets\operatorname{JoinComputationPLEP}^{\mathrm{Path}}(T_{b_1},T_{b_2},S_b) T b ← JoinComputationPLEP Path ( T b 1 , T b 2 , S b )
return T b T_b T b
else if b b b is an Introduce Edge node with child b ′ b' b ′ introducing edge ( u 0 , v 0 ) (u_0,v_0) ( u 0 , v 0 ) then
T b ′ ← TreeDP ( b ′ ) T_{b'}\gets\operatorname{TreeDP}(b') T b ′ ← TreeDP ( b ′ )
Define f 1 f_1 f 1 by
f 1 ( u , v ) = { 1 if u = u 0 and v = v 0 and u ≠ v , 0 if u = v , ⊥ otherwise f_1(u,v)=
\begin{cases}
1 & \text{if }u=u_0\text{ and }v=v_0\text{ and }u\ne v,\\
0 & \text{if }u=v,\\
\bot& \text{otherwise}
\end{cases} f 1 ( u , v ) = ⎩ ⎨ ⎧ 1 0 ⊥ if u = u 0 and v = v 0 and u = v , if u = v , otherwise f 2 ← { ( u , u ) ↦ 0 ∣ u ∈ S b } ∪ { ( u , v ) ↦ ⊥ ∣ u , v ∈ S b , u ≠ v } f_2\gets\{(u,u)\mapsto0\mid u\in S_b\}\cup\{(u,v)\mapsto\bot\mid u,v\in S_b,\ u\ne v\} f 2 ← {( u , u ) ↦ 0 ∣ u ∈ S b } ∪ {( u , v ) ↦ ⊥ ∣ u , v ∈ S b , u = v }
Define T T T by T [ f ] ≔ π ( u 0 , v 0 ) 1 { f = f 1 } + ( 1 − π ( u 0 , v 0 ) ) 1 { f = f 2 } T[f]\coloneqq\pi(u_0,v_0)\mathbf{1}_{\{f=f_1\}}+(1-\pi(u_0,v_0))\mathbf{1}_{\{f=f_2\}} T [ f ] : = π ( u 0 , v 0 ) 1 { f = f 1 } + ( 1 − π ( u 0 , v 0 )) 1 { f = f 2 }
T b ← JoinComputationPLEP P a t h ( T b ′ , T , S b ) T_b\gets\operatorname{JoinComputationPLEP}^{\mathrm{Path}}(T_{b'},T,S_b) T b ← JoinComputationPLEP Path ( T b ′ , T , S b )
return T b T_b T b
return TreeDP ( b r o o t ) \operatorname{TreeDP}(b_{\mathrm{root}}) TreeDP ( b root )
Figure 4 (PDF p. 33).
Then we say that Π ′ \Pi' Π ′ is an extension of Π \Pi Π . Further, we define E ( Π ) = { Π ′ ∣ Π ′ E(\Pi)=\{\Pi' \mid\Pi' E ( Π ) = { Π ′ ∣ Π ′ is an extension of Π } \Pi\} Π } as the set of all possible extensions of Π \Pi Π .
Example C.9. For example let us consider Π 0 = { ( v 1 , v 2 , v 3 , v 4 , v 5 ) , ( v 6 , v 7 , v 8 ) } \Pi_0=\{(v_1,v_2,v_3,v_4,v_5),(v_6,v_7,v_8)\} Π 0 = {( v 1 , v 2 , v 3 , v 4 , v 5 ) , ( v 6 , v 7 , v 8 )} . Then, by replacing ( v 1 , v 2 , v 3 , v 4 , v 5 ) (v_1,v_2,v_3,v_4,v_5) ( v 1 , v 2 , v 3 , v 4 , v 5 ) with ( v 1 , v 2 ) , ( v 2 , v 3 , v 4 ) , ( v 4 , v 5 ) (v_1,v_2),(v_2,v_3,v_4),(v_4,v_5) ( v 1 , v 2 ) , ( v 2 , v 3 , v 4 ) , ( v 4 , v 5 ) and replacing ( v 6 , v 7 , v 8 ) (v_6,v_7,v_8) ( v 6 , v 7 , v 8 ) with ( v 6 , v 7 ) , ( v 7 , v 8 ) (v_6,v_7),(v_7,v_8) ( v 6 , v 7 ) , ( v 7 , v 8 ) , we get that Π 0 ′ = { ( v 1 , v 2 ) , ( v 2 , v 3 , v 4 ) , ( v 4 , v 5 ) , ( v 6 , v 7 ) , ( v 7 , v 8 ) } \Pi'_0=\{(v_1,v_2),(v_2,v_3,v_4),(v_4,v_5),(v_6,v_7),(v_7,v_8)\} Π 0 ′ = {( v 1 , v 2 ) , ( v 2 , v 3 , v 4 ) , ( v 4 , v 5 ) , ( v 6 , v 7 ) , ( v 7 , v 8 )} is an extension of Π 0 \Pi_0 Π 0 .
We now show the claim corresponding to the case of Join nodes (note the similarity with Claim C.7):
Claim C.10. Let G = ( V , E , π ) \mathcal{G}=(V,E,\pi) G = ( V , E , π ) be a probabilistic graph with underlying non-probabilistic graph G = ( V , E ) G=(V,E) G = ( V , E ) , let S \mathcal{S} S be a nice tree decomposition of G G G , and let b b b be a Join node with children b 1 b_1 b 1 and b 2 b_2 b 2 . Note that S b = S b 1 = S b 2 S_b=S_{b_1}=S_{b_2} S b = S b 1 = S b 2 . Recall that we denote by G b 1 \mathcal{G}_{b_1} G b 1 and G b 2 \mathcal{G}_{b_2} G b 2 the probabilistic subgraphs induced by the subtrees rooted at b 1 b_1 b 1 and b 2 b_2 b 2 respectively. Let G 1 = ( V 1 , E 1 ) G_1=(V_1,E_1) G 1 = ( V 1 , E 1 ) and G 2 = ( V 2 , E 2 ) G_2=(V_2,E_2) G 2 = ( V 2 , E 2 ) be realisations of G b 1 \mathcal{G}_{b_1} G b 1 and G b 2 \mathcal{G}_{b_2} G b 2 respectively. Define H b = ( V 1 ∪ V 2 , E 1 ∪ E 2 ) H_b=(V_1\cup V_2,E_1\cup E_2) H b = ( V 1 ∪ V 2 , E 1 ∪ E 2 ) to be the graph formed by taking the union of G 1 G_1 G 1 and G 2 G_2 G 2 . Let f 1 = LDPL G 1 , S b 1 f_1=\operatorname{LDPL}_{G_1,S_{b_1}} f 1 = LDPL G 1 , S b 1 and f 2 = LDPL G 2 , S b 2 f_2=\operatorname{LDPL}_{G_2,S_{b_2}} f 2 = LDPL G 2 , S b 2 (recall Definition 5.5). Then the longest disjoint path length function for S b S_b S b in H b H_b H b , LDPL H b , S b \operatorname{LDPL}_{H_b,S_b} LDPL H b , S b is given by f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f:\operatorname{CPSP}_{S_b}\to\{0,1,\ldots,|V|-1\}\cup\{\perp\} f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } where
f ( Π ) = max Π 1 , Π 2 ∈ CPSP S b Π 1 ∪ Π 2 ∈ E ( Π ) , Π 1 ∩ Π 2 = ∅ [ f 1 ( Π 1 ) + f 2 ( Π 2 ) ] f(\Pi)=\max_{\substack{\Pi_1,\Pi_2\in\operatorname{CPSP}_{S_b}\\\Pi_1\cup\Pi_2\in E(\Pi),\ \Pi_1\cap\Pi_2=\varnothing}}\left[f_1(\Pi_1)+f_2(\Pi_2)\right] f ( Π ) = Π 1 , Π 2 ∈ CPSP S b Π 1 ∪ Π 2 ∈ E ( Π ) , Π 1 ∩ Π 2 = ∅ max [ f 1 ( Π 1 ) + f 2 ( Π 2 ) ] for each Π ∈ CPSP S b \Pi\in\operatorname{CPSP}_{S_b} Π ∈ CPSP S b , where ⊥ \perp ⊥ in arithmetic expressions is evaluated as − ∞ -\infty − ∞ (i.e., ⊥ + x = ⊥ \perp+x=\perp ⊥ + x =⊥ for each x ∈ N ∪ { ⊥ } x\in\mathbb{N}\cup\{\perp\} x ∈ N ∪ { ⊥ } , and ⊥ \perp ⊥ is smaller than all values of N \mathbb{N} N so it ignored in the max unless all arguments are ⊥ \perp ⊥ in which case the max evaluates to ⊥ \perp ⊥ ).
Proof. Consider any set Π ∈ CPSP S b \Pi\in\operatorname{CPSP}_{S_b} Π ∈ CPSP S b and let P \mathcal{P} P be a set of S b S_b S b -vertex-disjoint paths in H b H_b H b , such that Proj H b , S b ( P ) = Π \operatorname{Proj}_{H_b,S_b}(\mathcal{P})=\Pi Proj H b , S b ( P ) = Π .
Next for each path P ∈ P P\in\mathcal{P} P ∈ P we break it into multiple subpaths which consist of contiguous edges which lie entirely in G 1 G_1 G 1 or G 2 G_2 G 2 . By doing so we obtain two sets P 1 \mathcal{P}_1 P 1 and P 2 \mathcal{P}_2 P 2 such that the set P 1 \mathcal{P}_1 P 1 corresponds to a S b S_b S b -vertex-disjoint set of paths in G 1 G_1 G 1 and the set P 2 \mathcal{P}_2 P 2 corresponds to a S b S_b S b -vertex-disjoint set of paths in G 2 G_2 G 2 . Now we construct two sets Π 1 ∗ \Pi_1^* Π 1 ∗ and Π 2 ∗ \Pi_2^* Π 2 ∗ such that the projections of P 1 \mathcal{P}_1 P 1 and P 2 \mathcal{P}_2 P 2 are Π 1 ∗ \Pi_1^* Π 1 ∗ and Π 2 ∗ \Pi_2^* Π 2 ∗ respectively, i.e., Proj G 1 , S b ( P 1 ) = Π 1 ∗ \operatorname{Proj}_{G_1,S_b}(\mathcal{P}_1)=\Pi_1^* Proj G 1 , S b ( P 1 ) = Π 1 ∗ and Proj G 2 , S b ( P 2 ) = Π 2 ∗ \operatorname{Proj}_{G_2,S_b}(\mathcal{P}_2)=\Pi_2^* Proj G 2 , S b ( P 2 ) = Π 2 ∗ .
First we construct a set Π ′ \Pi' Π ′ which is an extension of Π \Pi Π . For each P ∈ P P\in\mathcal{P} P ∈ P consider Proj H b , S b ( P ) \operatorname{Proj}_{H_b,S_b}(P) Proj H b , S b ( P ) , the projection of P P P on S b S_b S b . For every P ∈ P P\in\mathcal{P} P ∈ P , we obtain a projection Proj H b , S b ( P ) ∈ Π \operatorname{Proj}_{H_b,S_b}(P)\in\Pi Proj H b , S b ( P ) ∈ Π which we replace with a collection of tuples in Π \Pi Π as follows: Suppose that Proj H b , S b ( P ) \operatorname{Proj}_{H_b,S_b}(P) Proj H b , S b ( P ) is given by ( v 1 , v 2 , … , v k ) (v_1,v_2,\ldots,v_k) ( v 1 , v 2 , … , v k ) . Let v a 1 = v 1 , v a 2 , … , v a m − 1 , v a m , v k v_{a_1}=v_1,v_{a_2},\ldots,v_{a_{m-1}},v_{a_m},v_k v a 1 = v 1 , v a 2 , … , v a m − 1 , v a m , v k denote the change-over vertices (see Definition C.6) of P P P in H b H_b H b , then in Π ′ \Pi' Π ′ we break each tuple at the locations of the change-over vertices. (Note that all change-over vertices must lie in S b S_b S b due to Claim C.7, hence they must occur in the projection of P P P on S b S_b S b ). Therefore, Π ′ \Pi' Π ′ contains a collection of disjoint tuples formed by partitioning the index set [ k ] [k] [ k ] into consecutive intervals and restricting ( v 1 , v 2 , … , v k ) ∈ Π (v_1,v_2,\ldots,v_k)\in\Pi ( v 1 , v 2 , … , v k ) ∈ Π to each tuple, with the endpoints overlapping. By repeating this procedure for all P ∈ P P\in\mathcal{P} P ∈ P , i.e., for all tuples in Π \Pi Π , we obtain Π ′ \Pi' Π ′ . Now note that since v a 1 = v 1 v_{a_1}=v_1 v a 1 = v 1 , v a 2 , … , v a m − 1 , v a m , v k v_{a_2},\ldots,v_{a_{m-1}},v_{a_m},v_k v a 2 , … , v a m − 1 , v a m , v k are the change-over vertices of P P P in H b H_b H b , every tuple v ( j ) v^{(j)} v ( j ) for all j = 1 , … , m j=1,\ldots,m j = 1 , … , m corresponds to the projection of a path in either G 1 G_1 G 1 or G 2 G_2 G 2 , and concatenation of these paths gives P P P .
Thus we partition Π ′ \Pi' Π ′ into two sets such that for every j j j , if the tuple v ( j ) v^{(j)} v ( j ) corresponds to a path in G 1 G_1 G 1 then we add v ( j ) v^{(j)} v ( j ) to Π 1 ∗ \Pi_1^* Π 1 ∗ , else if the tuple v ( j ) v^{(j)} v ( j ) corresponds to a path in G 2 G_2 G 2 then we add v ( j ) v^{(j)} v ( j ) to Π 2 ∗ \Pi_2^* Π 2 ∗ . By construction, note that Π ′ \Pi' Π ′ is an extension of Π \Pi Π , and that we have Π 1 ∗ ∪ Π 2 ∗ = Π ′ \Pi_1^* \cup\Pi_2^*=\Pi' Π 1 ∗ ∪ Π 2 ∗ = Π ′ , further it is easy to verify that Proj G 1 , S b ( P 1 ) = Π 1 ∗ \operatorname{Proj}_{G_1,S_b}(\mathcal{P}_1)=\Pi_1^* Proj G 1 , S b ( P 1 ) = Π 1 ∗ and Proj G 2 , S b ( P 2 ) = Π 2 ∗ \operatorname{Proj}_{G_2,S_b}(\mathcal{P}_2)=\Pi_2^* Proj G 2 , S b ( P 2 ) = Π 2 ∗ .
Note that the length of P P P in H b H_b H b is same as the sum of the lengths of P 1 \mathcal{P}_1 P 1 in G 1 G_1 G 1 and P 2 \mathcal{P}_2 P 2 in G 2 G_2 G 2 which are bounded above by f 1 ( Π 1 ∗ ) f_1(\Pi_1^*) f 1 ( Π 1 ∗ ) and f 2 ( Π 2 ∗ ) f_2(\Pi_2^*) f 2 ( Π 2 ∗ ) respectively.
Hence the following inequality holds:
Length ( P ) ≤ f 1 ( Π 1 ∗ ) + f 2 ( Π 2 ∗ ) ≤ max Π 1 , Π 2 ∈ CPSP S b Π 1 ∪ Π 2 ∈ E ( Π ) , Π 1 ∩ Π 2 = ∅ [ f 1 ( Π 1 ) + f 2 ( Π 2 ) ] . \operatorname{Length}(P)\leq f_1(\Pi_1^*)+f_2(\Pi_2^*)\leq\max_{\substack{\Pi_1,\Pi_2\in\operatorname{CPSP}_{S_b}\\ \Pi_1\cup\Pi_2\in E(\Pi),\ \Pi_1\cap\Pi_2=\varnothing}}[f_1(\Pi_1)+f_2(\Pi_2)]. Length ( P ) ≤ f 1 ( Π 1 ∗ ) + f 2 ( Π 2 ∗ ) ≤ Π 1 , Π 2 ∈ CPSP S b Π 1 ∪ Π 2 ∈ E ( Π ) , Π 1 ∩ Π 2 = ∅ max [ f 1 ( Π 1 ) + f 2 ( Π 2 )] .
In the case that P P P corresponds to the longest disjoint path length of Π \Pi Π , i.e., it has the greatest length among all possible sets of S b S_b S b -vertex disjoint paths in H b H_b H b which project to Π \Pi Π , the length of P P P must equal f ( Π ) f(\Pi) f ( Π ) by definition, further, P 1 \mathcal{P}_1 P 1 and P 2 \mathcal{P}_2 P 2 must also have the maximum length among all S b S_b S b -vertex disjoint paths which project to Π 1 \Pi_1 Π 1 and Π 2 \Pi_2 Π 2 in the graphs G 1 G_1 G 1 and G 2 G_2 G 2 respectively, so their lengths must equal f 1 ( Π 1 ∗ ) f_1(\Pi_1^*) f 1 ( Π 1 ∗ ) and f 2 ( Π 2 ∗ ) f_2(\Pi_2^*) f 2 ( Π 2 ∗ ) . Therefore, the first inequality is tight and is satisfied with equality. Further among all partitions ( Π 1 , Π 2 ) (\Pi_1,\Pi_2) ( Π 1 , Π 2 ) of an extension of Π \Pi Π , setting Π 1 = Π 1 ∗ \Pi_1=\Pi_1^* Π 1 = Π 1 ∗ and Π 2 = Π 2 ∗ \Pi_2=\Pi_2^* Π 2 = Π 2 ∗ (their union being the extension Π ′ \Pi' Π ′ ) must maximise f 1 ( Π 1 ) + f 2 ( Π 2 ) f_1(\Pi_1)+f_2(\Pi_2) f 1 ( Π 1 ) + f 2 ( Π 2 ) , else it would contradict the fact that P P P corresponds to the longest disjoint path length of Π \Pi Π . Hence the second inequality must hold with equality as well.
Hence, we obtain
f ( Π ) = max Π 1 , Π 2 ∈ CPSP S b Π 1 ∪ Π 2 ∈ E ( Π ) , Π 1 ∩ Π 2 = ∅ [ f 1 ( Π 1 ) + f 2 ( Π 2 ) ] . f(\Pi)=\max_{\substack{\Pi_1,\Pi_2\in\operatorname{CPSP}_{S_b}\\ \Pi_1\cup\Pi_2\in E(\Pi),\ \Pi_1\cap\Pi_2=\varnothing}}[f_1(\Pi_1)+f_2(\Pi_2)]. f ( Π ) = Π 1 , Π 2 ∈ CPSP S b Π 1 ∪ Π 2 ∈ E ( Π ) , Π 1 ∩ Π 2 = ∅ max [ f 1 ( Π 1 ) + f 2 ( Π 2 )] .
We are now ready to prove Claim 5.6, whose statement we recall here:
Claim 5.6. We can compute in XP parameterised by the treewidth of G \mathcal{G} G , for every bag S b S_b S b , a table T b T_b T b indexed with all possible functions f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f:\operatorname{CPSP}_{S_b}\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , such that T b [ f ] T_b[f] T b [ f ] equals the probability that in a random realisation H b H_b H b of G b \mathcal{G}_b G b , f f f is precisely LDPL H b , S b \operatorname{LDPL}_{H_b,S_b} LDPL H b , S b .
Proof. We prove that this is what Algorithm 5 does, by structural induction on the nice tree decomposition. We show that the algorithm applied to a bag b b b indeed computes, for every bag S b S_b S b , a table T b T_b T b indexed with all possible functions f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f:\operatorname{CPSP}_{S_b}\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , such that T b [ f ] T_b[f] T b [ f ] equals the probability that in a random realisation H b H_b H b of G b \mathcal{G}_b G b , the function f f f is precisely LDPL H b , S b \operatorname{LDPL}_{H_b,S_b} LDPL H b , S b . Clearly for a leaf node, the claim holds, since leaf nodes contain no vertices and longest disjoint path length function over the induced empty subgraph is the function f ∅ f_{\varnothing} f ∅ with f ∅ ( ∅ ) = 0 f_{\varnothing}(\varnothing)=0 f ∅ ( ∅ ) = 0 , which is what our algorithm assigns. Therefore the base case holds. Assume that the claim holds for the children of b b b . We now show that it holds for b b b as well:
Case 1: b b b is a Forget Vertex node Note that our definition of the subgraph induced at a node b b b covers all the edges introduced until that point and all the vertices (in the bag or any of its descendants). Hence if we let the child of b b b be b ′ b' b ′ , then G b = G b ′ \mathcal{G}_b=\mathcal{G}_{b'} G b = G b ′ . Therefore for any realisation H H H of G b \mathcal{G}_b G b , such that LDPL H , S b \operatorname{LDPL}_{H,S_b} LDPL H , S b is given by f f f , we have that in LDPL H , S b \operatorname{LDPL}_{H,S_b} LDPL H , S b we have the choice for every candidate path set projection Π \Pi Π over S b S_b S b of achieving the same candidate path set projection Π \Pi Π over S b S_b S b or of achieving a candidate path set projection Π ′ \Pi' Π ′ obtained by inserting the projected-away vertex of S b ′ ∖ S b S_{b'}\setminus S_b S b ′ ∖ S b as a singleton tuple or as an internal vertex of one tuple (i.e., inside one tuple but not as the first or last element). This is what we mean in the algorithm when we say that Π ′ \Pi' Π ′ projects to Π \Pi Π ; in particular Π \Pi Π projects to itself. The maximal possible length of an S b S_b S b -vertex-disjoint set of paths realising Π \Pi Π is then the maximum taken across these possibilities. Therefore the correctness of T b T_b T b follows directly from the correctness of T b ′ T_{b'} T b ′ obtained by induction hypothesis.
Case 2: b b b is an Introduce Vertex node. Nodes of this kind do not introduce any edges, and they only add an isolated vertex to the associated subgraph; they also have precisely one child. Let the child of b b b be b ′ b' b ′ ; then G b \mathcal{G}_b G b differs from G b ′ \mathcal{G}_{b'} G b ′ only by the addition of an isolated vertex, say v 0 v_0 v 0 . We are given that the probability that a random realisation of G b ′ \mathcal{G}_{b'} G b ′ admits the longest disjoint
Algorithm 5 DPComputationPLEP^{Path}( G = ( V , E , π ) , S ) (G=(V,E,\pi),S) ( G = ( V , E , π ) , S ) : Compute the probability distribution on the longest disjoint path length functions along a tree decomposition
Input: A probabilistic graph G = ( V , E , π : E → [ 0 , 1 ] ) G=(V,E,\pi:E\to[0,1]) G = ( V , E , π : E → [ 0 , 1 ]) of treewidth k k k and a nice tree decomposition S S S with root b r o o t b_{\mathrm{root}} b root
Output: A table T T T indexed with all possible functions C P S P S b r o o t → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } \mathrm{CPSP}_{S_{b_{\mathrm{root}}}}\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} CPSP S b root → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , such that T [ f ] T[f] T [ f ] is the probability that for any random realisation H b H_b H b of G G G , we have f = L D P L H b , S b r o o t f=\mathrm{LDPL}_{H_b,S_{b_{\mathrm{root}}}} f = LDPL H b , S b root
Function TreeDP( b ) (b) ( b ) :
T b ← T_b\gets T b ← for each f : C P S P S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f:\mathrm{CPSP}_{S_b}\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , set T b [ f ] = 0 T_b[f]=0 T b [ f ] = 0
if b b b is a Leaf node then
Let f ∅ f_{\varnothing} f ∅ be the function on C P S P ∅ = { ∅ } \mathrm{CPSP}_{\varnothing}=\{\varnothing\} CPSP ∅ = { ∅ } defined by f ∅ ( ∅ ) = 0 f_{\varnothing}(\varnothing)=0 f ∅ ( ∅ ) = 0
T b [ f ∅ ] ← 1 T_b[f_{\varnothing}]\gets1 T b [ f ∅ ] ← 1
return T b T_b T b
else if b b b is a Forget Vertex node with child b ′ b' b ′ then
T b ′ ← T_{b'}\gets T b ′ ← TreeDP( b ′ ) (b') ( b ′ )
foreach f ′ : C P S P S b ′ → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f':\mathrm{CPSP}_{S_{b'}}\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} f ′ : CPSP S b ′ → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } do
Define f f f by f ( Π ) = max Π ′ ∈ C P S P S b ′ , Π ′ projects to Π f ′ ( Π ′ ) f(\Pi)=\max_{\Pi'\in\mathrm{CPSP}_{S_{b'}},\ \Pi'\text{ projects to }\Pi}f'(\Pi') f ( Π ) = max Π ′ ∈ CPSP S b ′ , Π ′ projects to Π f ′ ( Π ′ )
T b [ f ] ← T b [ f ] + T b ′ [ f ′ ] T_b[f]\gets T_b[f]+T_{b'}[f'] T b [ f ] ← T b [ f ] + T b ′ [ f ′ ]
return T b T_b T b
else if b b b is an Introduce Vertex node with child b ′ b' b ′ introducing vertex v 0 v_0 v 0 then
T b ′ ← T_{b'}\gets T b ′ ← TreeDP( b ′ ) (b') ( b ′ )
foreach f ′ : C P S P S b ′ → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f':\mathrm{CPSP}_{S_{b'}}\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} f ′ : CPSP S b ′ → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } do
Define a function f : C P S P S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f:\mathrm{CPSP}_{S_b}\to\{0,1,\ldots,|V|-1\}\cup\{\bot\} f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ }
foreach Π ∈ C P S P S b \Pi\in\mathrm{CPSP}_{S_b} Π ∈ CPSP S b do
f ( Π ) : = { ⊥ if ∃ a non-singleton tuple t ∈ Π with v 0 ∈ t f ′ ( Π ′ ) otherwise, for Π ′ the restriction of Π to S b ′ f(\Pi):=\begin{cases}\bot& \text{if }\exists\text{ a non-singleton tuple }t\in\Pi\text{ with }v_0\in t\\ f'(\Pi') & \text{otherwise, for }\Pi'\text{ the restriction of }\Pi\text{ to }S_{b'}\end{cases} f ( Π ) := { ⊥ f ′ ( Π ′ ) if ∃ a non-singleton tuple t ∈ Π with v 0 ∈ t otherwise, for Π ′ the restriction of Π to S b ′
T b [ f ] ← T b [ f ] + T b ′ [ f ′ ] T_b[f]\gets T_b[f]+T_{b'}[f'] T b [ f ] ← T b [ f ] + T b ′ [ f ′ ]
return T b T_b T b
else if b b b is a Join node with children S b 1 , S b 2 S_{b_1},S_{b_2} S b 1 , S b 2 then
T b 1 ← T_{b_1}\gets T b 1 ← TreeDP( b 1 ) (b_1) ( b 1 )
T b 2 ← T_{b_2}\gets T b 2 ← TreeDP( b 2 ) (b_2) ( b 2 )
T b ← T_b\gets T b ← JoinComputationPLEP^{Path}( T b 1 , T b 2 , S b ) (T_{b_1},T_{b_2},S_b) ( T b 1 , T b 2 , S b )
return T b T_b T b
else if b b b is an Introduce Edge node with child S b ′ S_{b'} S b ′ introducing edge ( u 0 , v 0 ) (u_0,v_0) ( u 0 , v 0 ) then
T b ′ ← T_{b'}\gets T b ′ ← TreeDP( b ′ ) (b') ( b ′ )
Set f 1 f_1 f 1 as f 1 ( Π ) : = { 1 if Π contains ( u 0 , v 0 ) and no other non-singleton tuple 0 if Π contains only singleton tuples ⊥ otherwise f_1(\Pi):=\begin{cases}1 & \text{if }\Pi\text{ contains }(u_0,v_0)\text{ and no other non-singleton tuple}\\0 & \text{if }\Pi\text{ contains only singleton tuples}\\\bot& \text{otherwise}\end{cases} f 1 ( Π ) := ⎩ ⎨ ⎧ 1 0 ⊥ if Π contains ( u 0 , v 0 ) and no other non-singleton tuple if Π contains only singleton tuples otherwise
Define f 2 f_2 f 2 by f 2 ( Π ) : = { 0 if Π contains only singleton tuples ⊥ otherwise f_2(\Pi):=\begin{cases}0 & \text{if }\Pi\text{ contains only singleton tuples}\\\bot& \text{otherwise}\end{cases} f 2 ( Π ) := { 0 ⊥ if Π contains only singleton tuples otherwise
T [ f ] : = π ( u 0 , v 0 ) 1 { f = f 1 } + ( 1 − π ( u 0 , v 0 ) ) 1 { f = f 2 } T[f]:=\pi(u_0,v_0)\mathbf{1}_{\{f=f_1\}}+(1-\pi(u_0,v_0))\mathbf{1}_{\{f=f_2\}} T [ f ] := π ( u 0 , v 0 ) 1 { f = f 1 } + ( 1 − π ( u 0 , v 0 )) 1 { f = f 2 } .
T b ← T_b\gets T b ← JoinComputationPLEP^{Path}( T b ′ , T , S b ) (T_{b'},T,S_b) ( T b ′ , T , S b )
return T b T_b T b
return TreeDP( b r o o t ) (b_{\mathrm{root}}) ( b root )
Algorithm 6 JoinComputationPLEP≥ P a t h ^{\mathrm{Path}}_{\geq} ≥ Path ( T 1 , T 2 , S b ) (T_1,T_2,S_b) ( T 1 , T 2 , S b )
Input: A set of vertices S b S_b S b and two tables T 1 , T 2 T_1,T_2 T 1 , T 2 indexed with all possible functions CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } \operatorname{CPSP}_{S_b} \to\{0,1,\ldots,|V|-1\} \cup\{\bot\} CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ }
Output: A table T T T such that for any function f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f:\operatorname{CPSP}_{S_b} \to\{0,1,\ldots,|V|-1\} \cup\{\bot\} f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , the value T [ f ] T[f] T [ f ] is the probability that in a random realisation H b H_b H b of G b \mathcal{G}_b G b , we have LDPL H b , S b = f \operatorname{LDPL}_{H_b,S_b}=f LDPL H b , S b = f
For each f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f:\operatorname{CPSP}_{S_b} \to\{0,1,\ldots,|V|-1\} \cup\{\bot\} f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } , set T [ f ] ← 0 T[f]\leftarrow0 T [ f ] ← 0 ;
for each pair of functions ( f 1 , f 2 ) (f_1,f_2) ( f 1 , f 2 ) , f 1 , f 2 : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f_1,f_2:\operatorname{CPSP}_{S_b} \to\{0,1,\ldots,|V|-1\} \cup\{\bot\} f 1 , f 2 : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } do
foreach Π ∈ CPSP S b \Pi\in\operatorname{CPSP}_{S_b} Π ∈ CPSP S b do
Define f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } f:\operatorname{CPSP}_{S_b} \to\{0,1,\ldots,|V|-1\} \cup\{\bot\} f : CPSP S b → { 0 , 1 , … , ∣ V ∣ − 1 } ∪ { ⊥ } as follows:
f ( Π ) = max Π 1 , Π 2 ∈ CPSP S b Π 1 ∪ Π 2 ∈ E ( Π ) , Π 1 ∩ Π 2 = ∅ [ f 1 ( Π 1 ) + f 2 ( Π 2 ) ] f(\Pi)=\max_{\substack{\Pi_1,\Pi_2\in\operatorname{CPSP}_{S_b}\\ \Pi_1\cup\Pi_2\in E(\Pi),\ \Pi_1\cap\Pi_2=\varnothing}}[f_1(\Pi_1)+f_2(\Pi_2)] f ( Π ) = max Π 1 , Π 2 ∈ CPSP S b Π 1 ∪ Π 2 ∈ E ( Π ) , Π 1 ∩ Π 2 = ∅ [ f 1 ( Π 1 ) + f 2 ( Π 2 )] ;
T [ f ] ← T [ f ] + T 1 [ f 1 ] × T 2 [ f 2 ] T[f]\leftarrow T[f]+T_1[f_1]\times T_2[f_2] T [ f ] ← T [ f ] + T 1 [ f 1 ] × T 2 [ f 2 ]
return ( T ) (T) ( T )
path length function f f f is T b ′ [ f ] T_{b'}[f] T b ′ [ f ] , where T b ′ T_{b'} T b ′ is the table obtained as a result of the function call TreeDP( b ′ ) (b') ( b ′ ) , the correctness of which is guaranteed using our induction hypothesis. Therefore for any realisation H b ′ H_{b'} H b ′ of G b ′ \mathcal{G}_{b'} G b ′ such that LDPL H b ′ , S b ′ = f ′ \operatorname{LDPL}_{H_{b'},S_{b'}}=f' LDPL H b ′ , S b ′ = f ′ , we can map it to a realisation H b H_b H b of G b \mathcal{G}_b G b occurring with the same probability, differing only by the addition of a single isolated vertex v 0 v_0 v 0 . Note that such a map from realisations of G b ′ \mathcal{G}_{b'} G b ′ to realisations of G b \mathcal{G}_b G b is surjective. Given that LDPL H b ′ , S b ′ = f ′ \operatorname{LDPL}_{H_{b'},S_{b'}}=f' LDPL H b ′ , S b ′ = f ′ , we may construct the function f f f such that LDPL H b , S b = f \operatorname{LDPL}_{H_b,S_b}=f LDPL H b , S b = f in the following fashion: If the candidate path set projection Π \Pi Π contains a tuple ( v 1 , v 2 , … , v k ) (v_1,v_2,\ldots,v_k) ( v 1 , v 2 , … , v k ) which is a non-singleton tuple (i.e., k > 1 k>1 k > 1 ) and where we have v i = v 0 v_i=v_0 v i = v 0 for some i ∈ { 1 , 2 , … , k } i\in\{1,2,\ldots,k\} i ∈ { 1 , 2 , … , k } then the longest disjoint path length of Π \Pi Π is ⊥ \bot ⊥ , since v 0 v_0 v 0 is isolated. Otherwise, we use the image of the function f ′ f' f ′ on the candidate path set projection Π ′ \Pi' Π ′ obtained from Π \Pi Π by restricting it to vertices of S b ′ S_{b'} S b ′ , i.e., removing the singleton tuple v 0 v_0 v 0 if it exists (noting that this has no effect on the maximal length of paths realising the candidate path set projection).
Case 3: b b b is a Join node Let b b b be a Join node with children b 1 b_1 b 1 and b 2 b_2 b 2 . Consider realisations of G b 1 \mathcal{G}_{b_1} G b 1 and G b 2 \mathcal{G}_{b_2} G b 2 , say G 1 = ( V 1 , E 1 ) G_1=(V_1,E_1) G 1 = ( V 1 , E 1 ) and G 2 = ( V 2 , E 2 ) G_2=(V_2,E_2) G 2 = ( V 2 , E 2 ) respectively, such that the functions f 1 = LDPL G 1 , S b 1 f_1=\operatorname{LDPL}_{G_1,S_{b_1}} f 1 = LDPL G 1 , S b 1 and f 2 = LDPL G 2 , S b 2 f_2=\operatorname{LDPL}_{G_2,S_{b_2}} f 2 = LDPL G 2 , S b 2 are known. Consider the union of G 1 G_1 G 1 and G 2 G_2 G 2 which we define by H b = ( V 1 ∪ V 2 , E 1 ∪ E 2 ) H_b=(V_1\cup V_2,E_1\cup E_2) H b = ( V 1 ∪ V 2 , E 1 ∪ E 2 ) . Now, note that H b = ( V 1 ∪ V 2 , E 1 ∪ E 2 ) H_b=(V_1\cup V_2,E_1\cup E_2) H b = ( V 1 ∪ V 2 , E 1 ∪ E 2 ) is a realisation of G b \mathcal{G}_b G b , the probabilistic graph associated with the node b b b . By Claim C.10 , we know how to express the function LDPL H b , S b \operatorname{LDPL}_{H_b,S_b} LDPL H b , S b , the longest disjoint path length function of S b S_b S b in the graph H b = ( V 1 ∪ V 2 , E 1 ∪ E 2 ) H_b=(V_1\cup V_2,E_1\cup E_2) H b = ( V 1 ∪ V 2 , E 1 ∪ E 2 ) , from the functions LDPL H b 1 , S b \operatorname{LDPL}_{H_{b_1},S_b} LDPL H b 1 , S b and LDPL H b 2 , S b \operatorname{LDPL}_{H_{b_2},S_b} LDPL H b 2 , S b . Thus we can map pairs of realisations of G b 1 \mathcal{G}_{b_1} G b 1 and G b 2 \mathcal{G}_{b_2} G b 2 to realisations of G b \mathcal{G}_b G b , with the LDPL of the realisation of G b \mathcal{G}_b G b being determined from that of G b 1 \mathcal{G}_{b_1} G b 1 and G b 2 \mathcal{G}_{b_2} G b 2 . The resulting LDPL is computed by Algorithm 6 as prescribed by Claim C.10 .
Case 4: b b b is an Introduce Edge node Algorithm 5 treats the addition of the new edge from u 0 u_0 u 0 to v 0 v_0 v 0 as taking a union of the graph under consideration with another graph with the same vertex set and with a single edge from u 0 u_0 u 0 to v 0 v_0 v 0 , all other vertices being isolated. For the latter graph, the probability distribution over longest disjoint path length functions of S b S_b S b is trivially known and then we use Algorithm 6 like for the case of a Join node.
Proofs for Section 6 (Intractable Cases on Treewidth-2 Probabilistic Graphs)
Theorem 6.1. PLEP = P a t h \operatorname{PLEP}^{\mathrm{Path}}_{=} PLEP = Path and PLEP = W a l k \operatorname{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk are # P \#P # P -hard on probabilistic graphs of pathwidth 2.
Proof. We show this for PLEP = P a t h \operatorname{PLEP}^{\mathrm{Path}}_{=} PLEP = Path and observe that the same reduction extends to PLEP = W a l k \operatorname{PLEP}^{\mathrm{Walk}}_{=} PLEP = Walk . We
will give the argument with a graph of treewidth 2 (because the graph is simpler to construct and to draw), and explain at the end of the proof how the graph can be modified slightly to ensure that it has pathwidth 2.
We are given an instance φ \varphi φ of #PP2DNF built on the set of variables X = { X 1 , … , X p } X = \{X_1,\ldots,X_p\} X = { X 1 , … , X p } , Y = { Y 1 , … , Y q } Y = \{Y_1,\ldots,Y_q\} Y = { Y 1 , … , Y q } with k k k terms of the form X i r ∧ Y j r X_{i_r} \land Y_{j_r} X i r ∧ Y j r , where 1 ≤ r ≤ k 1 \le r \le k 1 ≤ r ≤ k . We let n = p + q n = p + q n = p + q be the number of variables of φ \varphi φ , and write # φ \#\varphi # φ for the number of satisfying assignments of φ \varphi φ , which is what we wish to compute. We construct the probabilistic graph G = ( V , E , π ) \mathcal{G} = (V,E,\pi) G = ( V , E , π ) described below (and illustrated in Figure 6 ).
Create a start vertex s s s .
Create vertices u 1 , u 2 , … , u p u_1,u_2,\ldots,u_p u 1 , u 2 , … , u p which will respectively correspond to the variables X 1 , X 2 , … , X p X_1,X_2,\ldots,X_p X 1 , X 2 , … , X p , and create vertices v 1 , … , v q v_1,\ldots,v_q v 1 , … , v q which will respectively correspond to the variables Y 1 , … , Y q Y_1,\ldots,Y_q Y 1 , … , Y q .
Create edges with probability 1 1 1 from u 1 u_1 u 1 to u 2 u_2 u 2 , from u 2 u_2 u 2 to u 3 u_3 u 3 , and so on, with the last such edge going from u p − 1 u_{p-1} u p − 1 to u p u_p u p .
Create a vertex u u u and an edge of probability 1 1 1 from u p u_p u p to u u u .
Create paths of 2 p 2p 2 p edges with probability 1 1 1 from v 1 v_1 v 1 to v 2 v_2 v 2 , from v 2 v_2 v 2 to v 3 v_3 v 3 , and so on, with the last such path going from v q − 1 v_{q-1} v q − 1 to v q v_q v q .
For each vertex u i u_i u i with i ∈ { 1 , … , p } i \in\{1,\ldots,p\} i ∈ { 1 , … , p } , create an edge from s s s to u i u_i u i having probability 1 2 \frac{1}{2} 2 1 .
For each vertex v j v_j v j with j ∈ { 1 , … , q } j \in\{1,\ldots,q\} j ∈ { 1 , … , q } , create an edge from u u u to v j v_j v j having probability 1 2 \frac{1}{2} 2 1 .
Last, create two vertices v v v and t t t , and an edge from v q v_q v q to v v v having probability 1 1 1 . Now, for each term X i r ∧ Y j r X_{i_r} \land Y_{j_r} X i r ∧ Y j r of the formula with 1 ≤ r ≤ k 1 \le r \le k 1 ≤ r ≤ k , construct a path from v v v to t t t of edges with probability 1 1 1 having length ( 2 p ) j r + i r (2p)j_r + i_r ( 2 p ) j r + i r .
Observe that the graph thus constructed has treewidth at most 2. Indeed, the part of the graph comprising the vertex s s s and the vertices u i u_i u i with i ∈ { 1 , … , p } i \in\{1,\ldots,p\} i ∈ { 1 , … , p } admits a path decomposition of width 2, as does the part of the graph comprising the vertices u u u and the vertices v j v_j v j with j ∈ { 1 , … , q } j \in\{1,\ldots,q\} j ∈ { 1 , … , q } . To see this observe that we can define the node b i b_i b i with the corresponding bag S b i S_{b_i} S b i to contain the vertices { s , u i , u i + 1 } \{s,u_i,u_{i+1}\} { s , u i , u i + 1 } . Connecting these nodes linearly to form a path b 1 , b 2 , … , b p − 1 b_1,b_2,\ldots,b_{p-1} b 1 , b 2 , … , b p − 1 gives a valid tree decomposition of the part of G \mathcal{G} G comprising s s s and u i u_i u i with i ∈ { 1 , … , p } i \in\{1,\ldots,p\} i ∈ { 1 , … , p } . A similar construction works for the part of the graph comprising the vertex u u u and the vertices v j v_j v j with j ∈ { 1 , … , q } j \in\{1,\ldots,q\} j ∈ { 1 , … , q } . Likewise, the part of the graph comprising v , t v,t v , t that encodes the conjunctive terms has a tree decomposition of width 2. We construct a tree decomposition as follows. Create a central node with bag { v , t } \{v,t\} { v , t } . For every v v v –t t t path of the form v , v 1 , v 2 , … , v m , t v,v_1,v_2,\ldots,v_m,t v , v 1 , v 2 , … , v m , t we build a path decomposition by introducing nodes b 1 , … , b m b_1,\ldots,b_m b 1 , … , b m , where for i = 1 , … , m − 1 i = 1,\ldots,m-1 i = 1 , … , m − 1 the bag of b i b_i b i is S b i = { v , v i , v i + 1 } S_{b_i} = \{v,v_i,v_{i+1}\} S b i = { v , v i , v i + 1 } and the bag of b m b_m b m is S b m = { v , v m , t } S_{b_m} = \{v,v_m,t\} S b m = { v , v m , t } . These nodes are connected linearly to form a path, and the node b m b_m b m is attached to the central node with bag { v , t } \{v,t\} { v , t } . Repeating this construction for every v v v –t t t path yields a tree decomposition in which every bag has size at most 3. Therefore, it may be concluded that the constructed graph has treewidth at most 2.
We now use the oracle for the P L E P P a t h \mathrm{PLEP}^{\mathrm{Path}} PLEP Path problem for the graph G = ( V , E , π ) \mathcal{G} = (V,E,\pi) G = ( V , E , π ) thus constructed, to compute the probability α \alpha α that there is a path of length exactly 2 p q + p + 4 2pq + p + 4 2 pq + p + 4 from s s s to t t t . We will return the value α 2 n \alpha2^n α 2 n . To establish the correctness of this reduction we must show that # φ = α 2 n \#\varphi= \alpha2^n # φ = α 2 n , or in other words α = # φ 2 n \alpha= \frac{\#\varphi}{2^n} α = 2 n # φ .
For this we define the function f f f which maps every assignment of variables θ \theta θ to a realisation f ( θ ) f(\theta) f ( θ ) of the probabilistic graph G = ( V , E , π ) \mathcal{G} = (V,E,\pi) G = ( V , E , π ) , where the edge from s s s to u i u_i u i is present if and only if X i X_i X i is true, and the edge from u u u to v j v_j v j is present if and only if Y j Y_j Y j is true, ∀ X i ∈ X \forall X_i \in X ∀ X i ∈ X and ∀ Y j ∈ Y \forall Y_j \in Y ∀ Y j ∈ Y . Clearly f f f is a bijection. We say that a realisation of G \mathcal{G} G is good if it contains a path of length exactly 2 p q + p + 4 2pq + p + 4 2 pq + p + 4 from s s s to t t t , and bad otherwise.
We then prove the following claim, which we denote by ( † ) (\dagger) ( † ) : the realisation f ( θ ) f(\theta) f ( θ ) is good if and only if θ \theta θ is a satisfying assignment.
To prove the forward implication, suppose first that θ \theta θ is a satisfying assignment. This implies that for some term of the #PP2DNF, say X i ∧ Y j X_i \land Y_j X i ∧ Y j , both variables X i X_i X i and Y j Y_j Y j are made true by θ \theta θ . Therefore the edges from s s s to u i u_i u i and from u u u to v j v_j v j must be present in f ( θ ) f(\theta) f ( θ ) . Therefore consider the path s , u i , u i + 1 … u p s,u_i,u_{i+1}\ldots u_p s , u i , u i + 1 … u p , which has length $1 + (p-i). C o n c a t e n a t e t h i s w i t h t h e e d g e j o i n i n g . Concatenate this with the edge joining . C o n c a t e na t e t hi s w i t h t h ee d g e j o inin g u_p and u u u . Next concatenate it with the path u u u , v j v_j v j , v j + 1 … v q v_{j+1}\ldots v_q v j + 1 … v q , which has length 1 + 2 p ( q − j ) 1+2p(q-j) 1 + 2 p ( q − j ) . Lastly concatenate it with the edge from v q v_q v q to v v v , and then with the path of length 2 p j + i 2pj+i 2 p j + i from v v v to t t t corresponding to X i ∧ Y j X_i\land Y_j X i ∧ Y j in the #PP2DNF formula.
The length of the path thus formed from s s s to t t t is then 1 + ( p − i ) + 1 + 1 + 2 p ( q − j ) + 1 + 2 p j + i 1+(p-i)+1+1+2p(q-j)+1+2pj+i 1 + ( p − i ) + 1 + 1 + 2 p ( q − j ) + 1 + 2 p j + i , i.e., 2 p q + p + 4 2pq+p+4 2 pq + p + 4 .
We now show the reverse implication. Suppose a path of length 2 p q + p + 4 2pq+p+4 2 pq + p + 4 exists. It must use exactly one path from v v v to t t t . Suppose it uses the path of length 2 p j + i 2pj+i 2 p j + i corresponding to a term X i ∧ Y j X_i\land Y_j X i ∧ Y j . The path must take exactly one blue edge of the form ( s , u i ′ ) (s,u_{i'}) ( s , u i ′ ) and exactly one blue edge of the form ( u , v j ′ ) (u,v_{j'}) ( u , v j ′ ) , in addition to the edges ( u p , u ) (u_p,u) ( u p , u ) and ( v q , v ) (v_q,v) ( v q , v ) . One can see that the path length is then 1 + ( p − i ′ ) + 1 + 2 p ( q − j ′ ) + 1 + 1 + 2 p j + i 1+(p-i')+1+2p(q-j')+1+1+2pj+i 1 + ( p − i ′ ) + 1 + 2 p ( q − j ′ ) + 1 + 1 + 2 p j + i , that is, 2 p ( q − j ′ + j ) + ( p − i ′ + i ) + 4 2p(q-j'+j)+(p-i'+i)+4 2 p ( q − j ′ + j ) + ( p − i ′ + i ) + 4 . By assumption this must be equal to 2 p q + p + 4 2pq+p+4 2 pq + p + 4 . Now, subtracting 4 from both sides, and using the fact that 0 < p − i ′ + i < 2 p 0<p-i'+i<2p 0 < p − i ′ + i < 2 p we can consider the Euclidean division of each side of the equation by 2 p 2p 2 p to conclude that ( q − j ′ + j ) = q (q-j'+j)=q ( q − j ′ + j ) = q and p − i ′ + i = p p-i'+i=p p − i ′ + i = p , so that we must have j = j ′ j=j' j = j ′ and i = i ′ i=i' i = i ′ . This implies that θ \theta θ is a satisfying assignment since the term X i ∧ Y j X_i\land Y_j X i ∧ Y j is satisfied.
Hence, this proves ( † ) (\dagger) ( † ) and concludes the proof except that the graph constructed so far has treewidth 2 and not pathwidth 2. We last explain how we can change the construction of the graph to ensure that it has pathwidth 2. The modification is that the parallel paths from v v v to t t t having different possible lengths are replaced by one path (for the longest length) together with shortcut edges to achieve the other lengths. Formally, we create one path from v v v to t t t of length M : = max 1 ≤ r ≤ k ( 2 p j r + i r ) M:=\max_{1\le r\le k}(2pj_r+i_r) M := max 1 ≤ r ≤ k ( 2 p j r + i r ) , and for each other desired length ( 2 p j r ′ + i r ′ ) (2pj_{r'}+i_{r'}) ( 2 p j r ′ + i r ′ ) for some r ′ r' r ′ we create one edge from v v v to the right vertex of this path to also ensure that there is a path of length ( 2 p ) j r ′ + i r ′ (2p)j_{r'}+i_{r'} ( 2 p ) j r ′ + i r ′ from v v v to t t t . This modification has no effect on the path lengths, more precisely the obvious bijection between the realisations of the original graph and of the modified graph ensures that there are precisely the same path lengths from s s s to t t t , so the rest of the correctness proof applies to the modified graph as well. (Note in particular that all edges in the modified part of the graph are deterministic.) Last, to explain why the modified graph has pathwidth 2, we have in fact already explained how to build a path decomposition of the vertices reachable from s s s and having a path to v v v , so all that remains is to continue the decomposition of the remainder of the graph. For this, we simply have bags of the form { v , w i , w i + 1 } \{v,w_i,w_{i+1}\} { v , w i , w i + 1 } , for w 1 , … , w M − 1 w_1,\ldots,w_{M-1} w 1 , … , w M − 1 the intermediary vertices created on the long path, and finish by one bag { v , w M − 1 , t } \{v,w_{M-1},t\} { v , w M − 1 , t } . This concludes the proof.
Proofs for Section 7 (Weighted Graphs)
Proposition 7.2. All PLEP variants are #P-hard on probabilistic weighted graphs, even when the input graphs are required to have pathwidth at most 2.
Proof of Proposition 7.2. We first show the claim for PLEP≤ W a l k {}^{\mathrm{Walk}}_{\leq} ≤ Walk , which implies the same for PLEP≤ P a t h {}^{\mathrm{Path}}_{\leq} ≤ Path because both problems are equivalent.
We reduce from the #KNAPSACK problem. Consider an instance of #KNAPSACK with S = { n 1 , … , n k } S=\{n_1,\ldots,n_k\} S = { n 1 , … , n k } and a threshold τ \tau τ . Let ϕ \phi ϕ be the number of subsets S ′ ⊆ S S'\subseteq S S ′ ⊆ S such that ∑ i ∈ S ′ i ≤ τ \sum_{i\in S'}i\leq\tau ∑ i ∈ S ′ i ≤ τ , which is the number that we want to compute. From the instance S , τ S,\tau S , τ , we construct the following probabilistic weighted graph G = ( V , E , π , δ ) \mathcal{G}=(V,E,\pi,\delta) G = ( V , E , π , δ ) as shown in Figure 2 :
Create a source vertex v 0 v_0 v 0 and vertices v 1 , … , v k v_1,\ldots,v_k v 1 , … , v k corresponding to the integers n 1 , … , n k n_1,\ldots,n_k n 1 , … , n k .
For every i ∈ { 1 , … , k } i\in\{1,\ldots,k\} i ∈ { 1 , … , k } , add an edge from v i − 1 v_{i-1} v i − 1 to v i v_i v i of weight n i + 2 n_i+2 n i + 2 and probability 1.
For every i ∈ { 1 , … , k } i\in\{1,\ldots,k\} i ∈ { 1 , … , k } , create a vertex u i u_i u i , create an edge of weight 1 and probability 1 from v i − 1 v_{i-1} v i − 1 to u i u_i u i , and create an edge of weight 1 and probability 1 / 2 1/2 1/2 from u i u_i u i to v i v_i v i .
It is easy to observe that G \mathcal{G} G has pathwidth 2, with a path decomposition featuring the bags { v 0 , u 1 , v 1 } , { v 1 , u 2 , v 2 } , … , { v k − 1 , u k , v k } \{v_0,u_1,v_1\},\{v_1,u_2,v_2\},\ldots,\{v_{k-1},u_k,v_k\} { v 0 , u 1 , v 1 } , { v 1 , u 2 , v 2 } , … , { v k − 1 , u k , v k } . Further, we consider the following bijection f f f between the set of subsets S ′ S' S ′ of S S S and the set of realisations of the graph G \mathcal{G} G : each subset S ′ ⊆ S S'\subseteq S S ′ ⊆ S is mapped to the realisation of G \mathcal{G} G where the edge from u i u_i u i to v i v_i v i (shown in blue in Figure 2) does not appear if and only if n i ∈ S ′ n_i\in S' n i ∈ S ′ . Let us say that a subset S ′ ⊆ S S'\subseteq S S ′ ⊆ S is good if its sum is no greater than τ \tau τ , and bad otherwise. Let us further say that a realisation of G \mathcal{G} G is good if it has a path from v 0 v_0 v 0 to v k v_k v k which is no longer than τ + 2 k \tau+ 2k τ + 2 k , and bad otherwise. We will now show the following claim (†): The set S ′ S' S ′ is good iff the realisation f ( S ′ ) f(S') f ( S ′ ) of G G G is good. As the probability of each realisation of G G G is 1 / 2 k 1/2^k 1/ 2 k , it is clear that (†) implies that we can obtain the answer to the #KNAPSACK instance (i.e., the number of good subsets S ′ ⊆ S S' \subseteq S S ′ ⊆ S ) from the total probability of the good realisations of G G G , simply by multiplying by 2 k 2^k 2 k . Hence, we show (†) in what follows.
First, we show that for any S ′ ⊆ S S' \subseteq S S ′ ⊆ S , if S ′ S' S ′ is good then f ( S ′ ) f(S') f ( S ′ ) is good. Consider any set S ′ S' S ′ such that ∑ i : n i ∈ S ′ n i ≤ τ \sum_{i:n_i\in S'} n_i \le\tau ∑ i : n i ∈ S ′ n i ≤ τ . Let the realisation G = ( V , E ′ ) G=(V,E') G = ( V , E ′ ) be the image of S ′ S' S ′ under f f f . Now consider the path P P P described as follows: P P P contains the vertices v 0 , v 1 , … v k v_0,v_1,\ldots v_k v 0 , v 1 , … v k in that order (in addition to possibly some intermediate vertices). If n i ∈ S ′ n_i\in S' n i ∈ S ′ then P P P contains the edge of weight n i + 2 n_i+2 n i + 2 from v i − 1 v_{i-1} v i − 1 to v i v_i v i , else P P P contains the path of length 2 via u i u_i u i from v i − 1 v_{i-1} v i − 1 to v i v_i v i , edges of which exist in G = ( V , E ′ ) G=(V,E') G = ( V , E ′ ) because n i ∉ S ′ n_i\notin S' n i ∈ / S ′ . Observe now that the total weight of P P P is ∑ i : n i ∈ S ′ ( n i + 2 ) + ∑ i : n i ∉ S ′ 2 \sum_{i:n_i\in S'}(n_i+2)+\sum_{i:n_i\notin S'}2 ∑ i : n i ∈ S ′ ( n i + 2 ) + ∑ i : n i ∈ / S ′ 2 , i.e., it is 2 k + ∑ i : n i ∈ S ′ n i 2k+\sum_{i:n_i\in S'}n_i 2 k + ∑ i : n i ∈ S ′ n i . Since ∑ i : n i ∈ S ′ n i ≤ τ \sum_{i:n_i\in S'}n_i\le\tau ∑ i : n i ∈ S ′ n i ≤ τ , we have ∑ i : n i ∈ S ′ n i + 2 k ≤ τ + 2 k \sum_{i:n_i\in S'}n_i+2k\le\tau+2k ∑ i : n i ∈ S ′ n i + 2 k ≤ τ + 2 k . Thus, f ( S ′ ) f(S') f ( S ′ ) is a good realisation.
Second, we show that for any S ′ ⊆ S S'\subseteq S S ′ ⊆ S , if f ( S ′ ) f(S') f ( S ′ ) is good then S ′ S' S ′ is good. So let S ′ ⊆ S S'\subseteq S S ′ ⊆ S and assume that the realisation ( V , E ′ ) = f ( S ′ ) (V,E')=f(S') ( V , E ′ ) = f ( S ′ ) of G G G is good, i.e., that it has a path P P P from v 0 v_0 v 0 to v k v_k v k which has length less than or equal to τ + 2 k \tau+2k τ + 2 k . We assume without loss of generality that P P P is a shortest path from v 0 v_0 v 0 to v k v_k v k , so that it uses the path of length 2 between any two adjacent vertices v i − 1 v_{i-1} v i − 1 and v i v_i v i whenever it is present. Thus, the length of P P P is ∑ i : n i ∈ S ′ ( n i + 2 ) + ∑ i : n i ∉ S ′ 2 = ∑ i : n i ∈ S ′ n i + 2 k \sum_{i:n_i\in S'}(n_i+2)+\sum_{i:n_i\notin S'}2=\sum_{i:n_i\in S'}n_i+2k ∑ i : n i ∈ S ′ ( n i + 2 ) + ∑ i : n i ∈ / S ′ 2 = ∑ i : n i ∈ S ′ n i + 2 k . However, we know that P P P has length ≤ τ + 2 k \le\tau+2k ≤ τ + 2 k . Thus, we have ∑ i : n i ∈ S ′ n i ≤ τ \sum_{i:n_i\in S'}n_i\le\tau ∑ i : n i ∈ S ′ n i ≤ τ , so S ′ S' S ′ is good. Thus, we have established both directions of (†).
Therefore if we have an oracle for the PLEP ≤ W a l k \operatorname{PLEP}^{\mathrm{Walk}}_{\le} PLEP ≤ Walk problem, we use the oracle to compute the probability p p p that there exists a path of length less than or equal to τ + 2 k \tau+2k τ + 2 k . Then 2 k p 2^kp 2 k p gives the number of subsets of S S S which sum to a value less than or equal to τ \tau τ , for the given instance of #KNAPSACK, which concludes the reduction and establishes the result for PLEP ≤ W a l k \operatorname{PLEP}^{\mathrm{Walk}}_{\le} PLEP ≤ Walk and PLEP ≤ P a t h \operatorname{PLEP}^{\mathrm{Path}}_{\le} PLEP ≤ Path .
We last explain how the proof can be modified to show the result for PLEP ≥ P a t h \operatorname{PLEP}^{\mathrm{Path}}_{\ge} PLEP ≥ Path and PLEP ≥ W a l k \operatorname{PLEP}^{\mathrm{Walk}}_{\ge} PLEP ≥ Walk . Given an instance of #KNAPSACK we modify the graph in the proof slightly while maintaining the same structure. In particular, the only change that we enforce is that all edges of weight 1 now appear with probability 1, whereas the weighted edges of weight n i + 2 n_i+2 n i + 2 where i ∈ { 1 , 2 , 3 , … , k } i\in\{1,2,3,\ldots,k\} i ∈ { 1 , 2 , 3 , … , k } now appear with a probability 1 2 \frac{1}{2} 2 1 .
Consider the map from subsets of the given set S S S to realisations of G G G in the proof above. Observe that a realisation of G G G has a path of length greater than τ + 2 k \tau+2k τ + 2 k if and only if the preimage corresponding to it is a subset of S S S which sums to a value greater than τ \tau τ . In other words a subset which sums to a value less than or equal to τ \tau τ maps to a realisation of G G G which does not have a path of length at least τ + 2 k + 1 \tau+2k+1 τ + 2 k + 1 .
Thus we call the oracle for the PLEP ≥ W a l k \operatorname{PLEP}^{\mathrm{Walk}}_{\ge} PLEP ≥ Walk problem to obtain the probability that there exists a path of length at least τ + 2 k + 1 \tau+2k+1 τ + 2 k + 1 . Let p p p be this probability. Then ( 1 − p ) 2 k (1-p)2^k ( 1 − p ) 2 k gives us the number of subsets of S S S which sum to a value less than or equal to τ \tau τ , concluding the reduction for PLEP ≥ P a t h \operatorname{PLEP}^{\mathrm{Path}}_{\ge} PLEP ≥ Path and PLEP ≥ W a l k \operatorname{PLEP}^{\mathrm{Walk}}_{\ge} PLEP ≥ Walk .
Proposition 7.4. For probabilistic weighted graphs of pathwidth 1, PLEP ≤ W a l k \operatorname{PLEP}^{\mathrm{Walk}}_{\le} PLEP ≤ Walk is #P-hard.
Proof. We reduce from the #UBK problem (Definition 7.6), which is #P-hard by Proposition 7.7. Given an instance of #UBK with S = { n 1 , n 2 , … , n k } S=\{n_1,n_2,\ldots,n_k\} S = { n 1 , n 2 , … , n k } and target τ \tau τ , we construct the graph G = ( V , E , π , δ ) \mathcal{G}=(V,E,\pi,\delta) G = ( V , E , π , δ ) as follows, outlined in Figure 3 .
Create a start vertex s s s
For every n i ∈ S n_i\in S n i ∈ S , create a vertex v i v_i v i
For each vertex v i v_i v i , create an edge of weight n i n_i n i and probability 1 2 \frac{1}{2} 2 1 from s s s to v i v_i v i
For each vertex v i v_i v i , create an edge of weight n i n_i n i and probability 1 from v i v_i v i to s s s
Observe that G = ( V , E , π , δ ) \mathcal{G}=(V,E,\pi,\delta) G = ( V , E , π , δ ) has pathwidth 1. Now consider the problem of determining if a walk of length 2 τ 2\tau 2 τ exists from s s s to s s s in this graph. Consider the obvious bijection f f f between subsets of S S S and realisations of G \mathcal{G} G , i.e., the edge from s s s to v i v_i v i is present in f ( S ) f(S) f ( S ) if and only if n i ∈ S n_i\in S n i ∈ S . We can immediately observe that f ( S ) f(S) f ( S ) contains a walk of length 2 τ 2\tau 2 τ from s s s to s s s iff S S S is feasible. Thus, the number of feasible subsets can be computed from the probability that G \mathcal{G} G contains a walk of length 2 τ 2\tau 2 τ from s s s to s s s , by multiplying by 2 k 2^k 2 k . This concludes the proof.
Proposition 7.7. The #UBK problem is #P-hard.
Proof. We reduce from the problem #WPP2DNF, for weighted #PP2DNF , defined as the following variant of #PP2DNF: given two sets of variables X = { X 1 , … , X p } X = \{X_1,\ldots,X_p\} X = { X 1 , … , X p } and Y = { Y 1 , … , Y q } Y = \{Y_1,\ldots,Y_q\} Y = { Y 1 , … , Y q } and a set ϕ \phi ϕ of terms each of the form X i ∧ Y j X_i \wedge Y_j X i ∧ Y j , we want to know the number of pairs ( ϕ ′ , θ ) (\phi',\theta) ( ϕ ′ , θ ) formed of a subset of terms ϕ ′ ⊆ ϕ \phi' \subseteq\phi ϕ ′ ⊆ ϕ and of valuations θ \theta θ of the variables X i ∪ Y j X_i \cup Y_j X i ∪ Y j such that ϕ ′ \phi' ϕ ′ evaluates to true under θ \theta θ . Intuitively, this is like #PP2DNF except every satisfying Boolean valuation θ \theta θ is counted as many times as there are subsets of terms whose disjunction satisfies θ \theta θ . The problem #WPP2DNF was introduced in [1 ] and is shown hard (under a different but equivalent terminology) in [5 Theorem 4.3] .
Now, from an instance ϕ \phi ϕ of #WPP2DNF with m m m terms built on the set of variables X = { X 1 , … , X p } X = \{X_1,\ldots,X_p\} X = { X 1 , … , X p } , Y = { Y 1 , … , Y q } Y = \{Y_1,\ldots,Y_q\} Y = { Y 1 , … , Y q } , we construct an instance of #UBK as follows. We let L = { n 1 , n 2 , … , n ∣ L ∣ } L = \{n_1,n_2,\ldots,n_{|L|}\} L = { n 1 , n 2 , … , n ∣ L ∣ } be a list of p + q + m p+q+m p + q + m integers that we define below. All integers are formed of 1 + 6 + p + q 1+6+p+q 1 + 6 + p + q bits decomposed in four blocks (from most to least significant digits): a 1, a block of 6 bits describing whether the integer codes an X X X -variable or Y Y Y -variable or a term, then a block of p p p bits coding the index of a X X X -variable, then a block of q q q bits coding the index of a Y Y Y -variable. The p + q + m p+q+m p + q + m integers are as follows:
For every variable X i X_i X i , we introduce in L L L an integer a i a_i a i . The binary representation of a i a_i a i is given as follows, from most to least significant bit. The first bit is 1, and the next six bits are 000001. The next p p p bits code the index of the variable in X X X , i.e., the i i i -th bit among these p p p bits is 1 and all other bits are 0. The next q q q bits are all 0 (they intuitively correspond to Y Y Y ).
For every variable Y j Y_j Y j , we introduce in L L L an integer b j b_j b j with binary representation given as follows. The first bit is 1, and the next six bits are 000100. The next p p p bits (intuitively corresponding to X X X ) are all 0. The next q q q bits intuitively correspond to the set Y Y Y and code the index of the variable in Y Y Y , i.e., the j j j -th bit among these q q q bits is 1 and all other bits are 0.
For every term X i ∧ Y j X_i \wedge Y_j X i ∧ Y j in ϕ \phi ϕ we introduce in L L L an integer c i j c_{ij} c ij with binary representation given as follows. The first bit is 1, and the next six bits are 010000. Then the i i i -th bit of the next p p p bits is 0 (coding X i X_i X i ) and the others are 1, and then the j j j -th bit of the next q q q bits is 0 (coding Y j Y_j Y j ) and the others are 1.
It is easy to check that this instance can be constructed in PTIME and that all resulting integers are pairwise distinct.
Further we let the target value be τ \tau τ , whose binary representation comprises p + q + 8 p+q+8 p + q + 8 bits given as follows: the first two bits are 1, the next six bits are 010101 and the next p + q p+q p + q bits are all 1.
Now we claim that the number of solutions to the #WPP2DNF instance is the same as the number of feasible solutions to the instance of #UBK constructed above. To establish this, we define the function f f f which maps every pair ( θ , ϕ ′ ) (\theta,\phi') ( θ , ϕ ′ ) of an assignment of variables θ \theta θ and a subset ϕ ′ ⊆ ϕ \phi' \subseteq\phi ϕ ′ ⊆ ϕ of terms to a set f ( θ , ϕ ′ ) ⊆ L f(\theta,\phi') \subseteq L f ( θ , ϕ ′ ) ⊆ L . The map is defined as follows. We have a i ∈ f ( θ , ϕ ′ ) a_i \in f(\theta,\phi') a i ∈ f ( θ , ϕ ′ ) precisely when the variable X i X_i X i is true in θ \theta θ , we have b j ∈ f ( θ , ϕ ′ ) b_j \in f(\theta,\phi') b j ∈ f ( θ , ϕ ′ ) precisely when the variable Y j Y_j Y j is true in θ \theta θ , and we have c i j ∈ f ( θ , ϕ ′ ) c_{ij} \in f(\theta,\phi') c ij ∈ f ( θ , ϕ ′ ) precisely when X i ∧ Y j X_i \wedge Y_j X i ∧ Y j is in ϕ ′ \phi' ϕ ′ . It is immediate that f f f is a bijection between subsets of L L L and pairs of a variable assignment and a subset of ϕ \phi ϕ .
Next we show the following claim (†): we have that θ \theta θ is a satisfying assignment of a subset ϕ ′ \phi' ϕ ′ of ϕ \phi ϕ if and only if f ( θ , ϕ ′ ) f(\theta,\phi') f ( θ , ϕ ′ ) is a feasible instance of the #UBK instance. The claim (†) ensures that the answer to the #UBK instance is precisely the answer to #WPP2DNF that we need to compute. Hence, all that remains is to show (†).
For this, in the forward direction, consider a pair ( θ , ϕ ′ ) (\theta,\phi') ( θ , ϕ ′ ) counted for the #WPP2DNF instance, formed of a subset ϕ ′ \phi' ϕ ′ of terms of ϕ \phi ϕ and an assignment θ \theta θ which satisfies ϕ ′ \phi' ϕ ′ . Thus there exist X i X_i X i and Y j Y_j Y j which are true under θ \theta θ and are such that X i ∧ Y j X_i \wedge Y_j X i ∧ Y j occurs in ϕ ′ \phi' ϕ ′ . Hence the integers a i , b j , c i j a_i,b_j,c_{ij} a i , b j , c ij occur in f ( θ , ϕ ′ ) f(\theta,\phi') f ( θ , ϕ ′ ) . Now, observe that a i + b j + c i j = τ a_i+b_j+c_{ij}=\tau a i + b j + c ij = τ . This shows that f ( θ , ϕ ′ ) f(\theta,\phi') f ( θ , ϕ ′ ) is a feasible subset of $L.
Now, in the backward direction, let f ( θ , ϕ ′ ) f(\theta,\phi') f ( θ , ϕ ′ ) be a feasible subset of L L L . We show that θ \theta θ must be a satisfying assignment of ϕ ′ \phi' ϕ ′ . Since f ( θ , ϕ ′ ) f(\theta,\phi') f ( θ , ϕ ′ ) is a feasible subset of L L L , there exists a tuple of weights { x 1 , x 2 … x ∣ L ∣ } \{x_1,x_2\ldots x_{|L|}\} { x 1 , x 2 … x ∣ L ∣ } , such that ∑ i = 1 ∣ L ∣ n i x i = τ \sum_{i=1}^{|L|} n_i x_i=\tau ∑ i = 1 ∣ L ∣ n i x i = τ , and only integers in f ( θ , ϕ ′ ) f(\theta,\phi') f ( θ , ϕ ′ ) have a nonzero weight in the tuple. We first claim that the tuple must consist of at most three integers, i.e., ∑ i = 1 ∣ L ∣ x i ≤ 3 \sum_{i=1}^{|L|}x_i\le3 ∑ i = 1 ∣ L ∣ x i ≤ 3 . This is because, looking at the two leading bits 11 of the target value, we know that every integer in L L L has value 01 on the bits at this position (remembering that the integers in L L L are one bit shorter than the target value). Thus, summing four or more of them, we would obtain a sum with at least p + q + 9 p+q+9 p + q + 9 bits, which would overshoot the target value τ \tau τ .
Now, we know that there exists at most three integers in the set L L L : we now show that there must be exactly three and that there must be one of the form a i a_i a i , one of the form b j b_j b j , and one of the form c i , j c_{i,j} c i , j . Indeed, in the target value τ \tau τ , the first two bits are 11, and the following six bits are given by 010101. Now, the bits at the corresponding position is 010000 for the c i , j c_{i,j} c i , j , 000100 for the b j b_j b j , and 000001 for the a i a_i a i . Thus, if two or three c i , j c_{i,j} c i , j ’s are added then the first among these six bits in the sum must be 1, which does not match the target. We can apply the same reasoning to the b j b_j b j about the next two bits in the sum, and so on, so we know that we can take at most one integer of each type. Now, to achieve the target, it is then clear that we must take in fact precisely one integer of each type.
Thus, we must end up adding exactly one of the integers corresponding to the set of variables X X X (say a i a_i a i for the variable X i X_i X i ), exactly one of the integers corresponding to the set of variables Y Y Y (say b j b_j b j for the variable Y j Y_j Y j ), and exactly one of the integers corresponding to the set of terms. We now claim that the integer corresponding to the set of terms must be c i , j c_{i,j} c i , j (for the term X i ∧ Y j X_i\wedge Y_j X i ∧ Y j ). Indeed, if we consider the sum of the integers a i + b j a_i+b_j a i + b j , only the i t h i^{\mathrm{th}} i th position among the p p p positions corresponding to the set of variables X X X and the j t h j^{\mathrm{th}} j th among the q q q positions corresponding to the set of variables Y Y Y are 1 and the rest are 0. The target requires us to add to a i + b j a_i+b_j a i + b j an integer that consists of 1 at all but these two positions. Thus, the third integer corresponding to a term is uniquely given by c i , j c_{i,j} c i , j . Now since a i , b j , c i , j ∈ f ( θ , ϕ ′ ) a_i,b_j,c_{i,j}\in f(\theta,\phi') a i , b j , c i , j ∈ f ( θ , ϕ ′ ) we must have that X i ∧ Y j X_i\wedge Y_j X i ∧ Y j is a term of ϕ ′ \phi' ϕ ′ and that X i , Y j X_i,Y_j X i , Y j are true in θ \theta θ , showing that θ \theta θ is a valid assignment of ϕ ′ \phi' ϕ ′ . This establishes the backward direction of (†), so (†) holds and the result is proven.