Manuscript Offprint
arXiv:2610.17887Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
We consider the problem of testing the existence of a source-to-target path satisfying an input-specified length constraint in an input probabilistic graph, as a simplified model of query evaluation on a probabilistic database. More precisely, we wish to determine the probability that a suitable walk or simple path exists, and consider the cases of a length constraint requiring the length to be at least , at most , or exactly , for a target length given as input and written in binary. The probabilistic graphs that we consider are directed graphs where each edge is annotated with an independent probability of existence. Our goal is to determine, given such a graph, endpoints, and length constraint, what is the probability that a requisite path/walk exists, i.e., the total probability of the outcomes that satisfy this requirement. As this task is generally intractable (#P-hard), we aim for algorithms applying to input graphs that are assumed to be of bounded treewidth.
We show that, in contrast to many other tasks on probabilistic graphs (e.g., computing the probability of MSO formulas), bounding the treewidth does not always imply tractability of our problems, and we characterise the resulting complexity landscape. Specifically:
We give an XP algorithm parameterised by treewidth to compute the probability that an input probabilistic graph contains a source-to-target path/walk of length , and do the same for a path/walk of length . This implies in particular that these problems are in PTIME on graphs whose treewidth is bounded by a constant.
We show that XP is likely the best one can hope for the four problems mentioned in the last item, as we show that these are W[1]-hard (under Turing reductions) parameterised by pathwidth (hence not FPT under the standard assumption that FPT≠W[1]). This is in contrast to the case of non-probabilistic graphs, where the corresponding problems were known to be FPT parameterised by treewidth; and to the connectivity problem (and more generally MSO evaluation) on probabilistic graphs, where the same was known.
Surprisingly, we show that it is #P-hard to compute the probability that an input graph contains a source-to-target path/walk of length exactly , even on graphs of pathwidth 2. By contrast, all our problems are tractable on graphs of treewidth 1.
Last, we investigate the complexity of our problems when the edges can carry weights. This causes all our problems to become #P-hard already on pathwidth-2 graphs, and causes specifically the “exactly ” walk problem to be #P-hard even on pathwidth-1 graphs.
2012 ACM Subject Classification Theory of computation → Design and analysis of algorithms
Keywords and phrases probabilistic graphs, tree decompositions, walks, simple paths
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.
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
1 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, a source s, and a target t, what is the probability that there is some path from s to t, i.e., what is the total probability of the graphs having such a path in the distribution represented by the graph G. We can of course always solve this problem exactly by considering every possible realisation of G, solving the (non-probabilistic) st-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, so this algorithm is inefficient. It has in fact been shown [35, Theorem 1] that ST-CON is #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 , the ST-CON problem can be solved in polynomial time when the input probabilistic graphs are restricted to have treewidth at most ; 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 to t has length less than some threshold, e.g., to check if t can be reached from 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-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-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 , or , or , for an integer threshold 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 ), it may make a difference in general because revisiting vertices may be useful to achieve higher lengths. This gives six problem combinations: , , and for paths; and , , and for walks.
For each of these six problems, the input consists of a probabilistic graph G, a source vertex s and target vertex , and the threshold . Our task is to compute the total probability of the realisations of where a suitable path from to exists. Our goal is to study the complexity of these problems when the input graph 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 and , 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 for some constant c and with 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 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 #P-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: , , , and . 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 and , then the problem which adds the computation of handling “arbitrarily high” walk lengths, then the problem 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 and 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 and 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 and 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 cannot be obtained simply by subtracting, e.g., the probability of existence of paths of length from the probability of existence of paths of length (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
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
| Walk | PTIME | PTIME | PTIME |
| Path | PTIME | NP-c.FPT | NP-c.FPT |
(a) On non-probabilistic graphs
| Walk | #P-h.XP (tw)W[1]-h. (pw) | #P-h. (pw 2)FP (tw 1) | #P-h.XPW[1]-h. |
| Path | #P-h.XP (tw)W[1]-h. (pw) | #P-h. (pw 2)FP (tw 1) | #P-h.XP (tw)W[1]-h. (pw) |
(b) On probabilistic graphs
Table 1 Summary of the complexity of the problems PLEP
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 PLEPWalk and PLEPPath 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 PLEPWalk specifically when we have weights and probabilities, remembering that the problem PLEPWalk was tractable on treewidth-1 unweighted probabilistic graphs.
We conclude in Section 8. Most detailed proofs are deferred to the appendix.
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 , where is an integer given as input in binary. This gives rise to 6 computational problems, which we denote PLEP for and , defined as follows ("PLEP" stands for Path Length Existence Problem):
PROBLEM: PLEP for and for
INPUT : A graph , two vertices , and an integer (given in binary)
OUTPUT : Decide whether a path/walk of length exists from to
For instance, the problem PLEP asks whether there is a path from to of length at most . Equivalently, it asks whether the length of a shortest path from to is at most . Further note that PLEP and PLEP are identical, because shortest walks are always paths; but the same is not true of PLEP and PLEP, or of PLEP and PLEP.
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 PLEP simply amounts to computing the length of a shortest path from to , which is PTIME. Problems PLEP and PLEP 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 PLEP is PTIME, using fast exponentiation of the graph's adjacency matrix. The problem PLEP is PTIME too, by creating copies of the graph and performing a reachability test (assuming without loss of generality that is at most ).
Probabilistic graphs. A probabilistic graph is a triple , where is a graph, called the underlying non-probabilistic graph, and assigns a probability value to every edge. A realisation of is a graph of the form for . The probabilistic graph defines a probability distribution on the set of its realisations, by keeping or discarding each edge with probability , independently across edges. Formally, for a given realisation of , its probability, denoted , is the quantity . Note that realisations may have probability 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 and for , the PLEP problem is as follows. We receive as input a probabilistic graph , vertices and , and an integer written in binary. Our task is to compute the sum over all of the probabilities of the realisations of that satisfy PLEP for , , and . Notice that the non-probabilistic setting is a special case of the probabilistic setting in which all edges have probability 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 with , where and are encoded in binary. All probability computation problems that we study are in FP#P, i.e., they can be solved in polynomial time with access to a #P oracle.
3 Treewidth
We have seen that already in the non-probabilistic setting, the PLEP problems may be intractable: this is specifically the case of PLEP and PLEP . 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 PLEP and PLEP 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 PLEP and PLEP 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 is a pair where is a rooted, unordered tree and where every node is assigned a vertex subset , called a bag, such that the following three conditions hold: (i) , in other words, every vertex of is in at least one bag; (ii) For every , there exists a node of such that the bag contains both and ; (iii) For every , the set induces a connected subtree of . The width of is , that is, the maximum size of its bags minus 1. The treewidth of a graph , denoted by , is the minimum
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
possible width of a tree decomposition of G. Likewise, we define the treewidth of a probabilistic graph 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 (resp., a probabilistic graph G) is the minimum possible width of a path decomposition of G (resp., of the underlying non-probabilistic graph of 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 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 have exactly two children, the bags of b and its children are identical, and 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 and a nice tree decomposition of , for a node in the tree , we define as the set of vertices included in any of the bags contained in the subtree rooted at . We further define as the graph whose vertices are and whose edges are exactly those that are introduced in some bag of the subtree rooted at . In particular, if is a join node with children , then is the disjoint union (in terms of edges) of and .
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 which, given as input a graph with two distinguished vertices and an integer , determines if , and if yes, computes a nice tree decomposition of of width at most whose root bag is , in time .
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 reduces to in polynomial time (using the fact that a simple path cannot be longer than ). Hence, we only need to show that 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, what are the “partial solutions” of the problem in the subgraph . 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 will intuitively be a bag of the tree decomposition.
▶ Definition 3.3. For a graph and a set of paths in , we call vertex-disjoint if for any two distinct paths , no vertex of occurs in . The length of , denoted length( ), is then the sum of lengths of the paths that contains. For , a set of paths is A-vertex-disjoint if it is vertex-disjoint, and for each path , the endpoints of are vertices in .
▶ Definition 3.4. Let be a graph, a set of vertices of , and a path in whose endpoints are vertices of . We define the projection of relative to and , written , to be the tuple comprising those vertices of that are in , in the order in which they occur in .
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 , i.e., P is a single-vertex path), but it may have more if some internal vertices of P are in A.
We extend this notion to define the projection of an A-vertex-disjoint set of paths P of G as ; we call such a set a path set projection. Finally, we define the disjoint path set projection of A relative to G, denoted by , to be the set of the path set projections of all A-vertex-disjoint sets of paths of G, formally, is an A-vertex-disjoint set of paths of G}.
The algorithm that we propose to solve over non-probabilistic bounded-treewidth graphs is then as follows. We process the tree decomposition bottom-up and, for every node of the decomposition, we compute the following information: (1.) the set , and (2.) for every path set projection , the set of natural numbers
{length(P) | P is an -vertex-disjoint set of paths of such that .
We briefly sketch how this information can be computed bottom-up. If is a leaf node the computation is easy, and if is a join node we can compute the information from the two children of . This is because, by the properties of nice tree decompositions, when is an -vertex-disjoint set of paths of , can be decomposed as a concatenation of some -vertex-disjoint sets of paths of and some -vertex-disjoint sets of paths of . Furthermore, since is a set of sets of tuples of vertices of , its size depends only on , so the total size of the information that we compute for every node of the tree decomposition is bounded by . When we reach the root bag , with and , we have the information we need to decide if there exists a simple path of length in from to , namely, consider the path set projection (or if ) and see whether the length was achieved for . All in all, this gives us an algorithm with complexity , i.e., FPT parameterised by treewidth, as promised.
4 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 (Section 5), and that hardness can be shown for the others (Section 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 for and are all -hard, even when the target length is given in unary.
To show Theorem 4.1, we reduce from the classical problem #PP2DNF:
As the reader might have understood, our focus in this paper is not to get the best possible.
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
▶ Definition 4.2. Let and be two disjoint sets of variables. A positive, partitioned, 2DNF (PP2DNF) over is a Boolean formula of the form , where and for . An assignment for is a function ; we call satisfying if there is some for which we have and . The problem #PP2DNF takes as input such a PP2DNF and outputs , the number of satisfying assignments of .
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 and Y as nodes respectively in the first and second partition, and connecting an X-variable to a Y-variable by an edge of probability 1 if they occur together in a term. We then add a source vertex s connected to all variables X by edges of probability , and likewise a target vertex t probabilistically connected to all variables Y. The probability that there exists a walk or path from s to t having length at most, at least, or exactly 3 is then easily seen to be equal to .
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, the problems for and can all be solved in linear time, up to the cost of arithmetic operations.
Proof sketch. As has treewidth one, there is at most one directed path from to . If no such path exists then the answer is zero, otherwise call the path . The problems , (equivalently ), and are then easy to solve, by first determining the length of , then comparing to the target input length , and returning, depending on this comparison, either 0, or the probability that exists (i.e., the product of the probabilities of its edges). For , if we can return 0 and if we can again return the probability that exists. Otherwise, we need that all edges of exist, but we must also take into account the possibility to have, in a realisation of , a path from to which is not simple and achieves the requisite length. If and do not have the same parity, this can only be achieved thanks to a self-loop, either on a vertex of 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 and 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 or using some return edge for an edge of . 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 is similar.
5 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, the problems for and are tractable on probabilistic graphs of treewidth at most 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 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 PLEP for and are 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) , that we write , which is W[1]-hard parameterised by pathwidth [24]. 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 -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 .
We now sketch the reduction. We first reduce #LE to the problem of counting the number of order-preserving maps of a poset into a chain. For a poset and , a q-order-preserving map is a function such that whenever , and the order polynomial of is the function that counts the number of such q-order-preserving maps. This first reduction relies on the known fact that the leading coefficient of the order polynomial of is equal to its number of linear extensions, divided by , 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 of gives a non-probabilistic edge and further every vertex gives a non-probabilistic edge . We then have probabilistic edges that give paths of every possible length from to each and from each to . We can show that, on realisations satisfying the path length requirements, the 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 to a position. The edges then enforce that this assignment corresponds to an order-preserving map.
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 (see Theorem 3.1) to probabilistic graphs.
Before we start, we quickly generalise the notation to probabilistic graphs in the expected way, as follows. For a probabilistic graph with underlying non-probabilistic graph , for a tree decomposition of , and for a node of , we write the probabilistic graph whose underlying non-probabilistic graph is and where the edge probabilities are as indicated
The authors of [24] show hardness when parameterised by treewidth, but in fact the authors of [13] (cf. [13, Section 1.1] and text before) notice that their proof also works for pathwidth.
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs

Figure 1 Example construction of the graph G from the proof of Proposition C.5, for q = 4 and for the poset P containing three elements x, y and z, with and and x and y being incomparable. The dotted blue lines are the coding edges, which are defined in the proof and intuitively correspond to probabilistic edges.
by G. Notice that, by the properties of nice tree decompositions, if b is a JOIN node with children , then the probability distribution of is the independent product of those of and .
5.1 At-Most Length Variants: PLEP and PLEP
Remember that and are different names for the exact same problem; we will use the name here. Further note that in our subsequent discussion we shall assume without loss of generality that . This is because if , then the probability that a path of length at most exists is the same as the probability that a path of length at most exists, hence it suffices to look at the instances where .
To prove Theorem 5.1 in the case of , we introduce an intermediate problem, that we call the shortest length probability distribution computation problem (SLPDC). The plan is to then reduce 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, two vertices s and t, and our aim is to compute, for every integer ranging from 0 to , the probability that the length of the shortest path from s to t is . In addition, we will want to compute the probability that no path from s to t exists at all: in this case we say that the shortest path length from s to t is . Formally:
PROBLEM: SLPDC (Shortest Length Probability Distribution Computation)
INPUT: A probabilistic graph , two vertices
OUTPUT: For every the probability that the shortest path from s to t is of length
We now reduce to SLPDC. Let be a probabilistic graph. Consider the SLPDC output for and the vertices and , seen as a table with giving the probability that the shortest path from to has length , for . Since all of these correspond to mutually exclusive events, the probability that there is a path of length at most from to can simply be computed as . Therefore, to prove Theorem 5.1 in the case of , 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 , define the shortest path length function for , written , to be the function such that for every , the value equals the length of a shortest path from to in , and if no path from to exists. For a set of vertices of , we denote by the restriction of to the domain .
Let be the probabilistic graph given as input of SLPDC, with a nice tree decomposition. The key idea to solve SLPDC is to compute, by bottom-up induction on , for every node of and for every possible function , the probability that, in a random realisation of , the function is precisely equal to . Note that, because there are such functions for each node , 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 , for each bag of , a table indexed with all possible functions such that equals the probability that in a random realisation of , the function is equal to .
Proof sketch. We proceed by bottom-up induction, and use the fact that is a separator of 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 of contributes to precisely one cell of the table . Moreover, each realisation of a JOIN node with children and can be obtained by picking independently realisations and of and , and then the shortest path length function is entirely determined from the shortest path length functions and of the children. Indeed, shortest paths in between vertices of can be decomposed into some combination of shortest paths in between vertices of and shortest paths in between vertices of , all of which are shortest paths. Hence, the total probability of the realisations achieving a specific shortest path length function can be computed by the total probability of the realisations and 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 whose root bag is precisely , 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 , a value that is the probability that in a random realisation of , equals . Now, since these are mutually exclusive events, for the probability that the shortest path from to is of length is simply given by , for ranging over all functions such that . This concludes the proof (sketch) of Theorem 5.1 in the case of .
5.2 At-Least Length Walk Variant: PLEP Walk
For PLEP we can modify the algorithm of the previous section for PLEP such that, for every node in the tree decomposition, we compute for every function from , the probability that represents the longest walk function, i.e., for every pair of vertices, represents the longest walk length from vertex to in a random realisation of . Note the additional possible value , which means that there are arbitrarily long walks from to , i.e., there is some cycle which is reachable from and from which 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 ).
5.3 At-Least Length Simple Path Variant: PLEP Path
We now explain how to show Theorem 5.1 in the case of PLEP , whose proof is of a different flavour than the last two. We reuse for this the notions of path set projections that we introduced
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
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 since we are looking for simple paths (if we can safely return 0).
We start by defining the longest length probability distribution computation (LLPDC) problem and reduce to LLPDC.
Longest Length Probability Distribution Computation. In the longest length probability distribution computation problem, we are given a probabilistic graph G, two vertices s and t, and our aim is to compute, for every integer ranging from 0 to , the probability that the length of the longest (simple) path from s to t is . In addition, we also seek to compute the probability that there does not exist a path from s to t, denoted . Formally:
PROBLEM: LLPDC (Longest Length Probability Distribution Computation)
INPUT: A probabilistic graph , two vertices
OUTPUT: For every the probability that the longest simple path from s to t is of length
It is then clear that we can reduce to LLPDC, in the same way as we reduced 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 Section 3, in particular the set of tuples of vertices which we defined for a graph and set of vertices (where 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 set of vertices, let be the full clique over A, i.e., the vertices of are A and its edges are . We then define the set of candidate path set projections of A, written , to be .
In other words, an element of is simply a set of tuples of elements of such that every occurs at most once in these tuples; and contains all such sets.
▶ Definition 5.5. Let be a graph and . The longest disjoint path length function relative to and , denoted : , is the function such that, for every candidate path set projection , the value is equal to the maximum length of an -vertex-disjoint set of paths of such that if such a exists, or to otherwise.
To solve LLPDC we will then compute, for every bag of the tree decomposition and every possible function , the probability that in a random realisation of , the function is precisely equal to . Before we explain this, let us show that this suffices to solve LLPDC. By applying this to the root bag , and noticing that , we obtain, for every function , the probability that in a random realisation of , the function equals ; let us call this value . Now, let be the specific path set projection (or in case ), which is in . Then, for , the probability that the longest path from to in has length exactly is equal to , where ranges over all functions that map to . This allows us to solve LLPDC, which we already argued is enough to solve . Thus, all that is needed to finish our XP algorithm for over bounded-treewidth probabilistic graphs is to show:
▶ Claim 5.6. We can compute in XP parameterised by the treewidth of , for every bag , a table indexed with all possible functions , such that equals the probability that in a random realisation of , is precisely .
We show this in Appendix C.3, relying again on the properties of nice tree decompositions to allow us to sum over mutually exclusive events and multiply independent events.
6 Intractable Cases on Treewidth-2 Probabilistic Graphs
In the previous section, we have shown that the problems for and 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 and . We show in this section that, somewhat unexpectedly, these two remaining problems can be -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 , recalling its definition from earlier (Definition 4.2). Formally:
▶ Theorem 6.1. PLEP and PLEP are -hard on probabilistic graphs of pathwidth 2.
Proof sketch. We show this for and observe that the same reduction works for . Given an instance of on variables , with terms of the type , where , we construct the probabilistic graph described below (and illustrated in Figure 6 in the appendix).
Create a start vertex s.
Create vertices which will respectively correspond to the variables , and create vertices which will respectively correspond to the variables .
Create edges with probability 1 from to , from to , and so on, with the last such edge going from to .
Create a vertex u and an edge of probability 1 from to u.
Create paths of 2p edges with probability 1 from to , from to , and so on, with the last such path going from to .
For each vertex with , create an edge from to having probability .
For each vertex with , create an edge from to having probability .
Last, create two vertices and , and an edge from to having probability 1. Now, for each term of the formula with , construct a path from to of edges with probability 1 having length .
Clearly 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 problem on , to compute the probability that there is a path of length exactly from to . We then return the value , for the number of variables of . The proof that this reduction is correct, i.e., that for the number of satisfying assignments of , can be found in Appendix D.
7 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 was tractable on arbitrary graphs (see Section 2) and was tractable on bounded-treewidth graphs (Theorem 3.1), it is easy to reduce the SUBSET-SUM problem to the exactly- problems, already on pathwidth-2 graphs:
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs

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 .
▶ Proposition 7.1. The PLEP Walk and 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 of natural numbers and a threshold (all written in binary), whether there exists a subset of such that . We construct the pathwidth-2 graph shown in Figure 2 (ignoring for now the edge dashing and edge colours): formally, we have vertices and , and for each , we have edges of weight 1 from to and from to , and an edge of weight from to . The graph obviously has pathwidth 2, with bags . Further, there is a clear bijection between the paths from to and the subsets of , given by the choice of whether to go from to for each edge by the length-2 path of weight 2 (we say that the path does not select ) or the single edge of weight (we say that the path selects it). Hence, the weight of such a path is for the subset of the integers that it selects. Via the bijection, this establishes that there is a path from to of total weight iff there is a subset of that sums to . Thus, the problem PLEP Path is NP-hard. As the graph is acyclic, the same immediately holds for PLEP Walk.
Note that the same reduction (up to contracting the 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 PLEP Path and 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 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.

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
By Theorem 6.1, we know that and are #P-hard, so it suffices to show this for the -variants and the -variants. We reduce from the #P-hard #KNAPSACK problem [11]:
▶ Definition 7.3. The problem #KNAPSACK asks, given a set of natural numbers and a threshold , all written in binary, how many subsets satisfy .
We can now show Proposition 7.2:
Proof sketch. We focus on and . Given an instance of #KNAPSACK, we build a graph similarly to the proof of Proposition 7.1, but some edges are made probabilistic – see Figure 2 for an illustration. The realisations of then correspond to subsets of , and we can ensure that the subset sums up to at most iff the corresponding realisation has some path of weight at most from to . For and , we do a variant of this reduction.
Hardness on pathwidth-1 graphs. We now show that the 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, 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 of integers and an integer (all given in binary), and we must decide whether there is a linear combination of the with nonnegative integer coefficients that sums to , i.e., whether there exist nonnegative integers such that .
In #UBK, we are given a UBK instance and we must count the number of subsets such that is a positive UBK instance. In other words:
▶ Definition 7.6. The problem #UBK takes as input a set of natural numbers and a threshold , all written in binary, and it outputs the number of subsets of that are feasible, i.e., such that there exist nonnegative integers which ensure that whenever and that .
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 on probabilistic weighted graphs of treewidth 1.
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
Proof sketch of Proposition 7.4. From a #UBK instance with target , we build the weighted probabilistic graph of Figure 3, where precisely one edge of each back-and-forth path from the centre vertex has probability 1/2. We then ask for the existence of a walk of length exactly from 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 .
We remark that we expect to be the only problem among our variants to be #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 is easy because it suffices to consider shortest paths which are again unique in treewidth-1 instances. We last expect that is in PTIME by an adaptation of the argument of Theorem 4.3. However, we leave the detailed study of this to future work.
8 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-hard on arbitrary probabilistic graphs (Theorem 4.1), with and being hard already on probabilistic graphs of pathwidth 2 (Theorem 6.1). The problems , , and 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, and 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 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 , , and ? 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 (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 and are hard on treewidth-2 graphs, and we know that and , as well as , are tractable on arbitrary weighted non-probabilistic graphs; this leaves open the 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]-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 and which are hard for pathwidth 2.
References
1 Antoine Amarilli. Complexity of #PP2DNF where we also count on the number of clauses. Theoretical Computer Science Stack Exchange. Version: 2019-03-19. URL: https://cstheory.stackexchange.com/q/42546.
2 Antoine Amarilli, Pierre Bourhis, and Pierre Senellart. Provenance circuits for trees and treelike instances. In ICALP, 2015. doi:10.1007/978-3-662-47666-6_5.
3 Antoine Amarilli, Pierre Bourhis, and Pierre Senellart. Tractable lineages on treelike instances: Limits and extensions. In PODS, 2016. doi:10.1145/2902251.2902301.
4 Antoine Amarilli and Ismail İlkan Ceylan. The dichotomy of evaluating homomorphism-closed queries on probabilistic graphs. LMCS, 18, 2022. doi:10.46298/lmcs-18(1:2)2022.
5 Antoine Amarilli and Benny Kimelfeld. Uniform reliability of self-join-free conjunctive queries. LMCS, 2022. doi:10.46298/lmcs-18(4:3)2022.
6 Antoine Amarilli and Mikaël Monet. Weighted counting of matchings in unbounded-treewidth graph families. In MFCS, 2022. doi:10.4230/LIPIcs.MFCS.2022.9.
7 Antoine Amarilli, Mikaël Monet, and Pierre Senellart. Conjunctive queries on probabilistic graphs: Combined complexity. In PODS, 2017. URL: https://arxiv.org/pdf/1703.03201, doi:10.1145/3034786.3056121.
8 Ei Ando. The complexity of computing path length distributions with edges i.i.d. random via local uniformity, 2026. arXiv:2607.10195.
9 Stefan Arnborg, Jens Lagergren, and Detlef Seese. Easy problems for tree-decomposable graphs. Journal of Algorithms, 12(2), 1991.
10 Yossi Azar, Edith Cohen, Amos Fiat, Haim Kaplan, and Harald Racke. Optimal oblivious routing in polynomial time. In STOC, 2003.
11 Pablo Barceló, Mikaël Monet, Jorge Pérez, and Bernardo Subercaseaux. Model interpretability through the lens of computational complexity, 2020. arXiv:2010.12265.
12 Paul Beame, Guy Van den Broeck, Eric Gribkoff, and Dan Suciu. Symmetric weighted first-order model counting. In PODS, 2015.
13 Rémy Belmonte, Eun Jung Kim, Michael Lampis, Valia Mitsou, and Yota Otachi. Grundy distinguishes treewidth from pathwidth. SIAM Journal on Discrete Mathematics, 36(3), 2022.
14 Matthias Bentert, Klaus Heeger, and Dušan Knop. Length-bounded cuts: Proper interval graphs and structural parameters. Journal of Computer and System Sciences, 126, 2022.
15 Meghyn Bienvenu, Diego Figueira, and Pierre Lafourcade. When is shapley value computation a matter of counting? Proceedings of the ACM on Management of Data, 2(2), 2024.
16 H. L. Bodlaender. Dynamic programming on graphs with bounded treewidth. In ICALP, 1988.
17 Hans L Bodlaender, Marek Cygan, Stefan Kratsch, and Jesper Nederlof. Deterministic single exponential time algorithms for connectivity problems parameterized by treewidth. Information and Computation, 243, 2015.
18 Marek Cygan, Fedor V. Fomin, Lukasz Kowalik, Daniel Lokshtanov, Daniel Marx, Marcin Pilipczuk, Michal Pilipczuk, and Saket Saurabh. Parametrized algorithms. Springer, 2016.
19 Marek Cygan, Stefan Kratsch, and Jesper Nederlof. Fast hamiltonicity checking via bases of perfect matchings. Journal of the ACM (JACM), 65(3), 2018.
20 Marek Cygan, Jesper Nederlof, Marcin Pilipczuk, Michał Pilipczuk, Johan MM Van Rooij, and Jakub Onufry Wojtaszczyk. Solving connectivity problems parameterized by treewidth in single exponential time. TALG, 18(2), 2022.
21 Daniel Deutch, Nave Frost, Benny Kimelfeld, and Mikaël Monet. Computing the Shapley value of facts in query answering. In Proceedings of the 2022 International Conference on Management of Data, 2022.
22 Sam Dittmer and Igor Pak. Counting linear extensions of restricted posets. The Electronic Journal of Combinatorics, 27(4), 2020. doi:10.37236/8552.
23 Pavel Dvořák and Dušan Knop. Parameterized complexity of length-bounded cuts and multicuts. Algorithmica, 80(12), 2018.
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Eduard Eiben, Robert Ganian, Kustaa Kangas, and Sebastian Ordyniak. Counting linear extensions: Parameterizations by treewidth. Algorithmica, 81(4), 2019.
Amir Kafshdar Goharshady and Fatemeh Mohammadi. An efficient algorithm for computing network reliability in small treewidth. Reliability Engineering & System Safety, 193, 2020.
Kristoffer Arnsfelt Hansen. Simple reduction to unbounded knapsack? Theoretical Computer Science Stack Exchange. URL: https://cstheory.stackexchange.com/q/1002.
Dušan Knop, Martin Koutecký, Tomáš Masařík, and Tomáš Toufar. Simplified algorithmic metatheorems beyond MSO: Treewidth and neighborhood diversity. LMCS, 15, 2019.
Stephan Kreutzer and Cristian Riveros. Quantitative monadic second-order logic. In LICS. IEEE, 2013.
Silviu Maniu, Reynold Cheng, and Pierre Senellart. An indexing framework for queries on probabilistic graphs. ACM Transactions on Database Systems (TODS), 42(2), 2017.
Silviu Maniu, Pierre Senellart, and Suraj Jog. An experimental study of the treewidth of real-world graph data. In ICDT, 2019.
J Scott Provan and Michael O Ball. The complexity of counting cuts and of computing the probability that a graph is connected. SIAM Journal on Computing, 12(4), 1983.
Arkaprava Saha, Ruben Brokkelkamp, Yllka Velaj, Arijit Khan, and Francesco Bonchi. Shortest paths and centrality in uncertain networks. PVLDB, 14(7), 2021.
Richard P. Stanley. Enumerative combinatorics, volume 1 of Cambridge Studies in Advanced Mathematics. Cambridge University Press, 2 edition, 2011.
Dan Suciu, Dan Olteanu, Christopher Ré, and Christoph Koch. Probabilistic databases. Synthesis lectures on data management, 3(2), 2011. ISBN: 978-1608456802.
Leslie G. Valiant. The complexity of enumeration and reliability problems. SIAM J. Comput., 8(3), 1979.
Leslie G Valiant. The complexity of computing the permanent. Theoretical computer science, 8(2), 1979.
Thomas Wolle. A framework for network reliability problems on graphs of bounded treewidth. In ISAAC, 2002.
Ye Yuan, Lei Chen, and Guoren Wang. Efficiently answering probability threshold-based shortest path queries over uncertain graphs. In DASFAA, 2010.
Michal Ziobro and Marcin Pilipczuk. Finding hamiltonian cycle in graphs of bounded treewidth: Experimental evaluation. Journal of Experimental Algorithms (JEA), 24, 2019.
A 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 of a graph is a tree decomposition of width of where each node is of one of the following five types:
LEAF node: has no children and .
■ INTRODUCE VERTEX node: has exactly one child and for some .
■ JOIN node: has exactly two children and and .
■ FORGET VERTEX node: has exactly one child and for some .
■ INTRODUCE EDGE node: has exactly one child such that , and has two distinguished vertices such that , demarcating the addition of an edge. We say that the edge is introduced at node . We additionally require that for every edge , the edge is introduced at exactly one bag.
Given a graph and a nice tree decomposition of , for any node in the tree , we define as the set of vertices included in any of the bags contained in the subtree rooted at . We further define as the graph whose vertices are and whose edges are exactly those that are introduced in some bag of the subtree rooted at . Formally, where is introduced in the subtree rooted at . In particular, for the root bag, we have and . We will use the following result, from [16]:
▶ Lemma 3.2 ([16]). There is an algorithm and a polynomial which, given as input a graph with two distinguished vertices and an integer , determines if , and if yes, computes a nice tree decomposition of of width at most whose root bag is , in time .
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 such that, given as input a graph and integer , determines if , and if yes, computes a tree decomposition of of width in time .
▶ Lemma A.2 ([18]). If a graph admits a tree decomposition of width , then it also admits a nice tree decomposition of width . Moreover, given a tree decomposition of of width , one can in time compute a nice tree decomposition of of width that has at most nodes in time.
And we will also use the following lemma to ensure that the root bag is exactly , which is also convenient for our algorithms.
▶ Lemma A.3. Consider a graph , a nice tree decomposition of and two vertices . Then we can compute in linear time in another nice tree decomposition where the root bag is exactly and where the width of is at most one more than the width of .
Proof. We add to every bag of the tree decomposition. Now there must be at least some node with a bag containing both and and potentially some other vertices. If then we make the root and we are done. Else, create another FORGET VERTEX node and join it to . Thus, and differ only by a single vertex such that . Repeat the process to form a linear chain of nodes until we arrive at a node with the corresponding bag containing only and set it to be the root. Note that due to the addition of , the bags corresponding to the
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs

Figure 4 The probabilistic graph from the proof of Theorem 4.1. Probabilities are indicated in the middle of edges.
LEAF nodes may no longer be empty. Hence, to preserve the nice tree decomposition property, for every LEAF node , we have after the addition of , so we create a new node with the corresponding bag and attach it to . Thus is now a LEAF node and becomes an INTRODUCE VERTEX node. By following the process mentioned above we obtain another tree decomposition which is nice, contains only and at the root, and has width at most one more than that of . It is easy to see that this procedure takes linear time.
We can now prove Lemma 3.2:
Proof of Lemma 3.2. Given a graph one may apply Lemma A.1 to verify if . Then, if indeed , we compute a tree decomposition of width . This step takes time, and so has size bounded by the same expression. Further using Lemma A.2, we may obtain from this tree decomposition a nice tree decomposition of width that has at most nodes. Finally using Lemma A.3 we may compute, in linear time, another nice tree decomposition where the root bag is exactly and where the width of is at most one more than the width of . Overall, up to changing the polynomial if necessary, this takes time, establishing the result.
B Proofs for Section 4 (Introducing Probabilities)
▶ Theorem 4.1. On probabilistic graphs, the problems for and are all -hard, even when the target length is given in unary.
Proof. We first prove this result for the problem . Let be a PP2DNF formula as in Definition 4.2. Define for convenience . Define to be the probabilistic graph having as set of vertices (with and being fresh nodes) and edges , with all edges of the form and having probability and all other edges having probability 1. For instance, letting , we show in Figure 4.
Now, let be the probability that there exists a path from to in ; notice that we have , so that it is enough to argue that we can compute .
Let us call our oracle to to determine if there exists a path of length 3 from to . Since all paths from to have length 3, if the output of the oracle is , we may return as the number of satisfying solutions to the formula. This concludes the proof in the case of .
Now, observe that since all paths from to 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 to . Hence the same reduction shows that , , , , , are all #P-hard.
▶ Theorem 4.3. For probabilistic graphs of treewidth 1, the problems for and 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 st-walk of length
Input: A graph , vertices , and an integer representing the desired walk length
Output: Probability that a walk of length exists from to in
1 Let be the unique path from to (if no such path exists, return 0 as the probability);
2 if then
3 | return 0;
4 end
5 if then
6 | ;
7 | return ;
8 end
9 if then
10 | set of all vertices which have a self-loop in ;
// is the probability that there no vertex of has a self-loop
11 | ;
12 | set of all vertex pairs with and and the edges and exist in ;
// is the probability that there is no back-and-forth edge pair outside of incident to a vertex of
13 | ;
14 | set of all vertex pairs with and the edge occurs in and the back edge exist in ;
// is the probability that there is no return edge for any forward edge of
15 | ;
// return probability that exists and we have one self-loop on a vertex of or back-and-forth on or on an edge incident to
16 | return ;
17 end
18 else
// critical length to reach a self-loop and change parity
19 | ;
20 | foreach do
// explore the tree rooted at without the edges of
21 | edges of ;
22 | tree rooted at of the connected component of in ;
// compute the probability that we can reach a self-loop from
23 | ;
24 | end
// return probability that exists and there is a vertex of from which we can reach a self-loop
25 | return ;
26 end
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
Proof. Note that if a graph has treewidth 1, then it implies that either there is a unique directed path from to or is not reachable from . 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 where we need to find the probability of existence of a path of length , we can check if the length of the unique directed path from to is . If there is no to path or if the length of the unique directed path from to does not equal we return 0, else we return the multiplication of the probabilities over all the edges in this path. For (or equivalently ) where the desired path length threshold is , we again check if a path from to exists, check whether its length is less than or equal to 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 .
The only remaining cases are and . We propose Algorithm 1 for , which may be adapted to as well. Throughout the algorithm, the probability is always implicitly 0 if there is no edge from to . We give more details here on why the algorithm works.
Let be the unique directed path from to . (If no such path exists, we simply return 0). If the length of is , and the desired walk length threshold is then the case where is easy since there cannot exist a walk from to with length less than that of the unique directed path . Likewise when , the only possible walk from to with length is itself, hence in this case we return the multiplication of the probabilities associated with the edges of .
We now turn to the case where . We make two cases on the basis of the parity of . Note that if , then a realisation of contains a walk of length from to if and only if at least one of these three kinds of edges is present in , in addition to the directed path .
There exists a vertex such that there exists a self-loop at the vertex in (i.e., an edge from to )
There exist two adjacent vertices such that there is an edge from to and an edge from to in
There exist two vertices such that and there exists an edge from to and an edge from to in
Therefore if , then the required probability of a walk of length from to being present in is the probability that the path is present, and at least one of these three conditions outlined above is satisfied. Note that up to the parity of , these conditions are independent of the specific value of .
Let us now look at the case when . In such a case, we can show that given a realisation of there exists a walk of length from to in if and only if there exists a vertex such that a retraceable path of length at most exists from to another vertex , possibly not in , such that contains a self-loop, i.e., there is an edge from to . By a retraceable path we mean a path in , where besides every forward edge in the path , the corresponding back edge must also be present in . The idea is that we can take the path from to , diverge from to , take the self-loop attached to sufficiently many times, retrace back to the vertex and then continue along the path from to . However, this self-loop cannot be located too far from , in particular, if it is at a distance of greater than from , then visiting from and returning back to will necessarily cause the length of walk from to to exceed . So in this case, the natural algorithm is to compute, for every vertex on the path , the probability that there is a path of length less than or equal to the maximum length from to another vertex with self-loop, where .
We compute this quantity using Algorithm 2. Intuitively, at every node w reachable from v without going through an edge of P and without exceeding the maximum length, letting be the probability that the current node w has a self-loop, then the probability that we can reach a self-loop from w and come back within our allotted maximum length can be expressed as follows. It is 1 if the self-loop on w is present, which happens with probability . Otherwise, it is the independent OR of the probabilities that we can reach a self-loop from for each child and come back, weighted by the probabilities that the edges to and back are present, and multiplying by the recursively computed quantity on 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 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 . Again, we find the unique directed path from to (if it exists, else we return 0). Let its length be . If the desired length is such that , then clearly such a walk exists if and only if the directed path exists.
Otherwise, if , we take the independent disjunction across all possible ways to make the walk longer than . (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 , all back-edges corresponding to a forward edge of , and all pairs of back-and-forth edges not in that lead out of a vertex of ; and we multiply this by the probability that all edges of exist (i.e., we do precisely like the case of in Algorithm 1).
Algorithm 2 Compute the probability that we can reach a self-loop with the indicated budget
Input: directed rooted tree , current node , length budget
Output: Probability that we can reach a self-loop within budget and come back
1 Function GetExProb( ):
2 if then
3 | return 0;
4 end
// is implicitly 0 if
5 return
C Proofs for Section 5 (Tractable Cases on Bounded-Treewidth Probabilistic Graphs)
C.1 Proofs of the W[1]-Hardness Result
In this section we prove the following result.
▶ Theorem 5.2. On probabilistic acyclic graphs, the problems for and are -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 , a subset of the edges, and some parameters , and that is either true
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
or false for these inputs. For instance, could take a graph , a subset , and as parameters a source and target and integer , and is satisfied only if there exists a path of length from to in . For such a property , define the probabilistic computation problem for to be the problem where the input is a probabilistic graph and some parameters , and the output is the sum, across all such that has the property , of . Define also the generalised cardinality computation problem for to take as input a graph , a subset , some parameters , and some natural number , and the goal is to compute how many subsets of size are such that satisfies property . Intuitively, the edges of 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 as above, there is a polynomial-time Turing reduction from the generalised cardinality problem for P to the probabilistic computation problem for P.
Proof. Let , , and the input instance for the generalised cardinality problem for , and let . For define to be the number of subsets of size such that satisfies property . We will show how to compute all the values, which is enough since we only need .
For a natural number, define to be the probabilistic graph where for every and for every . Then, denoting the result of the probabilistic computation problem for on and , we have:
We then use the oracle to the probabilistic computation problem for to compute values for pairwise different values of . We then solve the system of linear equations given by Equation (1) (which is invertible because its matrix is a Vandermonde matrix with pairwise different values of ), to compute in polynomial time all the values for as we wanted. This concludes the proof.
With this in place, we now focus on proving Theorem 5.2. Remember that the problems and are the same problems. We first provide a proof of a weaker statement that applies only to 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.
C.1.1 First Proof of W[1]-hardness for PLEP
First, we show that is -hard when we consider undirected graphs (as opposed to the directed graphs we usually consider in this article). The definition of on undirected graphs is the same as when we have directed graphs, except that the input is now an undirected probabilistic graph (with containing pairs of the form for , ). We show:
▶ Proposition C.2. On probabilistic undirected graphs, the problem is -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 , two vertices (called source and target), and two integers . For a subset of edges , we say that is an -cut if every path from to of length at most contains an edge in ; in other words, if and are at distance in the graph where we have removed all edges of . The goal of the problem is then to determine if there exists an -cut of size at most . This problem has been shown to be -hard parameterised by pathwidth in [23, 14].
We now explain the reduction. Let , , be the input instance to MLBC, and let . For , define to be the number of -cuts of size . Notice then that the goal is simply to determine if . For , denote by the number of subsets of size of that are not -cuts, i.e., . Then, by what precedes, if we can compute all the numbers for , we can solve the MLBC problem on this instance. We will do this using our oracle for , and more specifically we invoke Lemma C.1 with the property being the following: it takes a graph , a subset and parameters and , and it is satisfied if is not an -cut for . The probabilistic computation problem for this property is precisely our target problem . Thus, via the reduction of Lemma C.1, we can use our oracle to solve the generalised cardinality computation problem for , i.e., to compute in polynomial time for every the number of subsets of size such that is not an -cut (we set , i.e., there are no exogenous facts). Since the number of subsets of size that are not an -cut is equal to the number of subsets of size such that is not an -cut, we can indeed compute in polynomial time all the numbers , 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 of the undirected graph with the gadget shown in Figure 5, with and 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 the directed graph obtained from in this fashion. Let us write and call the coding edges the set of edges of of the form , and the set of all other edges, that we call the exogenous edges. For a set of edges , let be the set of coding edges of that they correspond to, i.e., . We then observe the following: is not an -cut of if and only if is not a -cut of . Adapting the reduction is then straightforward, using in the generalised cardinality problem to force the exogenous edges not to be considered in a cut, and also noting that the transformation from to only multiplies the treewidth by a constant factor (indeed, the two fresh vertices introduced
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs

Figure 5 Gadget to adapt the reduction of Proposition C.2 to directed graphs.
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).
Last, we remark here that this proof could be adapted to show the W[1]-hardness of the variants, if one could show that the corresponding cut problems (i.e., we want that there is no path of length at least connecting s and t) are W[1]-hard; however to our knowledge this is not known.
C.1.2 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 for and , and that in addition shows hardness already for the case of acyclic probabilistic graphs. We focus first on the case of and explain after that why the proof also works for the other variants. For any integer , we write for the set .
The source of hardness will be the problem of counting the linear extensions of a partially ordered set (poset). Recall that a poset is a set together with a relation that is reflexive, transitive and antisymmetric. For , we say that covers , written , if we have , we have , and for every such that it holds that or . The cover graph of (also called the Hasse diagram) is the graph , i.e., whose vertices are the elements of , and which contains a directed edge whenever . A linear extension of is a permutation which ensures that, for every , if then .
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 is W[1]-hard under Turing reductions parameterised by the treewidth of , 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 , 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-order-preserving map from a poset is a map which ensures that, for every , if then . Notice that is allowed; in fact, notice that the linear extensions of correspond exactly to the -order-preserving maps of that are bijective. The problem of counting order-preserving maps for posets then takes as input a poset , an integer given in unary, and outputs the number of q-order-preserving maps of . 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 , to the problem of counting the number of order-preserving maps of posets.
Proof. For a poset , let be the number of q-order-preserving maps of . It is known that is a polynomial of degree in the variable , and that its leading coefficient is equal to the number of linear extensions of divided by : see for instance [33, paragraph before
Example 3.12.2]. Thus, using the problem of counting order-preserving maps as an oracle to compute on different values of (which we write in unary), we can recover in polynomial time the number of linear extensions of (this is again inverting a Vandermonde matrix, or equivalently, performing Lagrange interpolation to compute the coefficients of the degree- polynomial from the evaluation in points). This is clearly a valid FPT reduction as the poset has not been modified.
Thus, all that is needed to show the W[1]-hardness of PLEP 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 PLEP , parameterised by pathwidth, on acyclic probabilistic graphs.
Proof. Let be the input poset and be an integer given as input (in unary); our goal is to compute the number of q-order-preserving maps of . Let . Build a directed graph as follows:
-
for every element , we have a vertex and a vertex ;
-
for every , we have an edge ;
-
for every such that , we have an edge ;
-
we have for two fresh source and target vertices and ;
-
for every and every , we have a fresh path of length from to ;
-
for every and every , we have a fresh path of length from to ;
Notice that is indeed a directed acyclic graph. We now let 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 the coding edges. We let denote all other edges, and call them exogenous. This construction is illustrated in Figure 1 on a small poset with 3 elements. For , let be the set of edges of that are on the path from to or on the path from to , and call them the -related coding edges. Notice that with the union being disjoint. It is not hard to check that the pathwidth of is at most , for the pathwidth of the cover graph of . Indeed, from a path decomposition of the cover graph of , we can simply replace each element of by the two vertices and , add and 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 PLEP , via Lemma C.1, to solve the generalised cardinality computation problem for the property defined as follows: given a graph , vertices and , the length , and a subset , the property is satisfied if contains a path of length . Observe that the probabilistic computation problem for this property is precisely our target problem PLEP . Now, consider the generalised cardinality computation problem with the set of exogenous edges , and the target cardinality for the sets . The oracle for the generalised cardinality computation problem thus allows us to compute the number of subsets of cardinality such that contains a path from to of length . By changing variables and counting over the complements of relative to instead, this is equal to the number of subsets of cardinality such that contains a path from to of length . From this, we deduce the number of subsets of cardinality such that does not contain a path from to of length . We now claim that is equal to the number of -order-preserving maps of , which would conclude the proof because we can then simply return , 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 of size such that contains no path from to of length , and the -order-preserving maps of .
Let be such a set. For , let be one plus the length of the longest path from to in if such a path exists, and 1 otherwise. Notice that is in . We will show that the function that associates to is a -order-preserving map. Let be one plus the length of the longest path from to in if such a path exists, and 1 otherwise; and
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
define . Thanks to the edges from Item 2, we have that (as otherwise we would have a path of length > from to in ), i.e., . Furthermore, having implies that : this is intuitively because we have paths of every possible length in from to and likewise from to 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 to requires edge removals. Now, because with the union being disjoint, and because , we must have in fact that for each . This implies that we must have for . Indeed, we know that , and if we have then we have which by the decrement argument earlier would require > edge removals, exceeding our budget of for this . Now, thanks to the edges of Item 3, for every with , we must also have that , i.e., , so because we showed that . We have established that is order-preserving on the cover relation <_{\mathcal{P}}, which thanks to transitivity is sufficient to establish that we have for all with , e.g., by considering a chain and combining the inequalities. Thus, we have indeed shown that the function is a -order-preserving map.
Conversely, if is a -order-preserving map, let us define as follows. For , we put in all the edges of that lie on a path from to of length at least (there are such edges), as well as all those that lie on a path from to of length at least (there are such edges). It is clear then that , so we only need to argue why it is the case that contains no path of length from to . Let be a longest path in from to , if it exists (otherwise there is nothing to show). By construction of , paths from to must either go through an edge of the form with (case 1), or through an edge of the form (case 2). For case 1, by definition of and by construction of , we have that and , and we see that the part of between and has length and that the part between and has length , so that the total length of the path is . But since is order-preserving, hence the length of is at most . For case 2, if a path uses an edge of the form , then we have and the length of the path is exactly . Therefore, indeed contains no path of length from to .
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 PLEP and equivalently PLEP because the constructed graph is acyclic. Namely, the 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 variants of PLEP , i.e., to PLEP (or PLEP which is the same problem). We use oracle calls to PLEP to compute the number of subsets of size such that contains no path of length . It is then routine to check that the rest of the proof also adapts. Namely, we have a bijection between the subsets of size such that contains no path from to of length , and the -order-preserving maps of . This is shown in the forward direction by defining, for each set , the value is the length of the shortest path from to if such a path exists and otherwise, and similarly for . We deduce that so , and the disjoint union argument with the dual observation that incrementing the length of shortest paths requires one edge removal per increment implies that for each . The rest of the proof of the forward direction follows by defining , i.e., whenever we must have so 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 from by deleting the edges of the shortest paths from to and of the shortest paths from to . This concludes the proof of Theorem 5.2.
C.2 Proofs for At-Most Length Variants
In this section we first prove Claim 5.3 used for showing the tractability of 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 of a JOIN node with children and which can be obtained by picking independently realisations and of and , we need additional machinery to determine the shortest path length function from the shortest path length functions , . 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 to another . To that effect, we define the All Pairs Shortest Path Problem.
All Pairs Shortest Path Problem. In this problem, a weighted directed graph is given and we must determine the length of the shortest path from vertex to vertex for all such pairs of vertices, where denotes that the edge does not exist, and where the values returned can be when no path exists from one vertex to another. (In other words, behaves like , but we do not use 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 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:
Algorithm: ALG–APSP(G): (All Pairs Shortest Path Algorithm)
INPUT: A weighted graph
OUTPUT: A table with values in such that for any pair of vertices , the length of a shortest path from to in is given by (with denoting that no such path exists).
Next, we define a change-over vertex of a path P from a vertex s to another vertex t.
▶ Definition C.6. Let and be two graphs, with and possibly some vertices in common, and let be the union of these two graphs. Let be any path from to in . A change-over vertex of is a vertex satisfying either of the following properties:
v is an endpoint of P, namely v = s or v = t.
Otherwise, letting and be the vertices immediately before and after v, then the edge joining and v belongs to and the edge joining v and belongs to , 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 be a probabilistic graph with underlying non-probabilistic graph , let be a nice tree decomposition of , and let be a JOIN node with children and . Note that . Recall that we denote by and the probabilistic subgraphs induced by the subtrees rooted at and respectively. Let and be realisations of and respectively. Define to be the graph formed by taking the union of and . Consider any path in from a vertex to a vertex where . Then:
-
Any change-over vertex belonging to the path P must necessarily belong to .
-
Define to be the weighted directed graph with set of vertices and with weights for all , where and , where ignores in its arguments except when both arguments
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
are in which case it evaluates to . Then we have , where is given as follows: For every , equals the length of a shortest path from to in the weighted directed graph
Proof. We first prove Item 1. Let be a change-over vertex. If is or then by hypothesis. Otherwise, there are with an edge of and an edge of . By definition of and , this implies that occurs both in the subtree rooted at and in the subtree rooted at , hence by the connectedness property of tree decompositions must also occur in .
We now prove Item 2. First, we prove that, for any , the shortest path from to in is no longer than the shortest path from to in . Let be any shortest path from to in . Let the change-over vertices appearing in , in that order, be (); by Item 1 we know that they are all in . Moreover by the definition of change-over vertex, the edges appearing between any two consecutive change-over vertices and for lie exclusively in either or . But the shortest path from to lying exclusively in has length whereas the shortest path lying exclusively in has length , therefore if we consider the shorter of these two paths then it has length and is shorter than any other path lying exclusively in or . Therefore the length of the section of the path between must be equal to (otherwise would not be a shortest path from to ). The total length of the path is therefore . Now consider the path in . Observe that the length of this path is which is precisely the length of , i.e., the length of any shortest path from to in . This establishes that, indeed, the shortest path from to in is no longer than the shortest path from to in .
Next we show that the path is indeed the shortest path in . Suppose by contradiction that there is a shorter path where and . Then we replace every edge of weight with a path of equal length in : if then replace the edge with a shortest path from to in , otherwise, if , then replace it with a shortest path from to in . Thus, we now obtain a path from to in with length . Further by assumption . However, is the length of , a shortest -t path in . Thus, we arrive at a contradiction. Hence, is indeed the shortest path from to in , and its length is the same as that of shortest path from to in , 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, for each bag of S, a table indexed with all possible functions such that equals the probability that in a random realisation of , the function is equal to 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. We now show that it holds for b as well:
Case 1: is a Forget Vertex node Note that our definition of the subgraph induced at a node 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 be ; then . Therefore for any realisation of such that is given by , we can map it to the same realisation of occurring with the same probability, the shortest path length function now being given by the restriction of to . Therefore the correctness of follows directly from the correctness of obtained by induction hypothesis.
Case 2: 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 are thus in bijection with those of , where the bijection adds the single isolated vertex . 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 from to itself, no path from to any other vertex or to from any other vertex, and that the shortest path length among other vertices is unchanged. The correctness of again follows directly from that of obtained by induction hypothesis.
Case 3: is a Join node Let be a JOIN node with children and . Consider realisations of and , say and respectively, such that the functions and are known. Consider the union of and which we define by . Now, note that is a realisation of , the probabilistic graph associated with the node . By Claim C.7, we know that is given by the function where for all , the value equals the length of the shortest path from to in the weighted graph with weight function , and this holds for every realisation. Thus we can map pairs of realisations of and to realisations of , with the shortest path function of the realisation of being determined from the shortest path functions of and . The resulting shortest path function is computed by Algorithm 4 as prescribed by Claim C.7.
Case 4: b is an Introduce Edge node Algorithm 3 treats the addition of the new edge from to as taking a union of the graph under consideration with another graph with a single edge from to 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.
C.3 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 in probabilistic graphs of bounded treewidth. Like in the case of we provide an algorithm (Algorithm 5) which computes, for every bag in the tree decomposition, the probability distribution over the longest disjoint path length functions of in . In other words, it computes, for every , the probability that for a random realisation of , we have . Further, like in the case of , 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 , which we define next.
▶ Definition C.8. Let be a finite set of vertices. Consider any , where is the set of candidate path set projections of (recall Definition 5.4). Let , thus is a collection of disjoint tuples. Let be a set such that satisfies the following property:
For each non-singleton tuple , the set contains a collection of tuples formed by partitioning the index set into consecutive intervals and restricting to each tuple, with the endpoints overlapping.
More formally, we keep each singleton tuple as-is, and we replace every non-singleton tuple by a finite sequence of tuples for which there exist indices
such that
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
Algorithm 3 DPComputationPLEP (G = (V, E, ), S): Compute the probability distribution on the shortest path length function along a tree decomposition
Input: A probabilistic graph of treewidth and a nice tree decomposition with root
Output: A table indexed with all possible functions
, such that is the probability that for any pair of vertices in the length of the shortest path from to is (with denoting that no such path exists).
1 Function TreeDP(b):
2 For each , set
3 if is a LEAF node then
4
5 return
6 else if is a FORGET VERTEX node with child then
7
8 foreach do
9 Let be the restriction of to
10
11 return
12 else if is an INTRODUCE VERTEX node with child introducing vertex then
13
14 foreach do
15 Define by
16
17 return
18 else if is a JOIN node with children then
19
20
21
22 return
23 else if is an INTRODUCE EDGE node with child introducing edge then
24
25 Define by
26
27 Define by
28
29 return
30 return TreeDP( )
Algorithm 4 JoinComputationPLEP (T , T , S )
Input: A set of vertices and two tables , indexed with all possible functions
Output: A table such that for any function , the value is the probability that the shortest distance from vertex to in a realization of is given by
1 For each , set ;
2 for each pair where do
3 ;
4
5
6 return
Then we say that is an extension of . Further, we define is an extension of as the set of all possible extensions of .
▶ Example C.9. For example let us consider . Then, by replacing with and replacing with , we get that is an extension of .
We now show the claim corresponding to the case of JOIN nodes (note the similarity with Claim C.7):
▶ Claim C.10. Let be a probabilistic graph with underlying non-probabilistic graph , let be a nice tree decomposition of , and let be a JOIN node with children and . Note that . Recall that we denote by and the probabilistic subgraphs induced by the subtrees rooted at and respectively. Let and be realisations of and respectively. Define to be the graph formed by taking the union of and . Let and (recall Definition 5.5). Then the longest disjoint path length function for in , is given by where for each , where in arithmetic ,
expressions is evaluated as (i.e., for each , and is smaller than all values of so it ignored in the max unless all arguments are in which case the max evaluates to ).
Proof. Consider any set and let be a set of -vertex-disjoint paths in , such that .
Next for each path we break it into multiple subpaths which consist of contiguous edges which lie entirely in or . By doing so we obtain two sets and such that the set corresponds to a -vertex-disjoint set of paths in and the set corresponds to a -vertex-disjoint set of paths in . Now we construct two sets and such that the projections of and are and respectively, i.e., and .
First we construct a set which is an extension of . For each consider , the projection of on . For every , we obtain a projection which we replace with a collection of tuples in as follows: Suppose that is given by . Let denote the change-over vertices (see Definition C.6) of in , then in we break each tuple at the locations of the change-over vertices. (Note that all change-over vertices must lie in due to Claim C.7, hence they must occur in the projection of on ). Therefore, contains a collection of disjoint tuples formed by partitioning the index set into consecutive intervals and restricting to each tuple, with the endpoints overlapping. By repeating this procedure for all , i.e., for all tuples in , we obtain .
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
Now note that since are the change-over vertices of in , every tuple for all corresponds to the projection of a path in either or , and concatenation of these paths gives .
Thus we partition into two sets such that for every , if the tuple corresponds to a path in then we add to , else if the tuple corresponds to a path in then we add to . By construction, note that is an extension of , and that we have , further it is easy to verify that and .
Note that the length of in is same as the sum of the lengths of in and in which are bounded above by and respectively.
Hence the following inequality holds:
Length of
In the case that corresponds to the longest disjoint path length of , i.e., it has the greatest length among all possible sets of -vertex disjoint paths in which project to , the length of must equal by definition, further, and must also have the maximum length among all -vertex disjoint paths which project to and in the graphs and respectively, so their lengths must equal and . Therefore, the first inequality is tight and is satisfied with equality. Further among all partitions of an extension of , setting and (their union being the extension ) must maximise , else it would contradict the fact that corresponds to the longest disjoint path length of . Hence the second inequality must hold with equality as well.
Hence, we obtain
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 , for every bag , a table indexed with all possible functions : , such that equals the probability that in a random realisation of , is precisely .
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 indeed computes, for every bag , a table indexed with all possible functions , such that equals the probability that in a random realisation of , the function is precisely . 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 with , which is what our algorithm assigns. Therefore the base case holds. Assume that the claim holds for the children of . We now show that it holds for as well:
Case 1: is a Forget Vertex node Note that our definition of the subgraph induced at a node 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 be , then . Therefore for any realisation of such that the LDPL is given by , we have that in LDPL we have the choice for every candidate path set projection over of either achieving the same candidate path set projection over or of achieving a candidate path set projection obtained by inserting the projected-away vertex of 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 projects to ; in particular projects to itself. The maximal possible length of an -vertex-disjoint set of paths realising is then the maximum taken across these possibilities. Therefore the correctness of follows directly from the correctness of obtained by induction hypothesis.
Case 2: 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 be ; then differs from only by the addition of an isolated vertex, say . We are given that the probability that a random realisation of admits the longest disjoint
Algorithm 5 DPComputationPLEP ( ): Compute the probability distribution on the longest disjoint path length functions along a tree decomposition
Input: A probabilistic graph of treewidth and a nice tree decomposition with root
Output: A table indexed with all possible functions
CPSP , such that is the probability that for any random realisation of , we have
1 Function TreeDP( ):
2 for each : CPSP , set
3 if is a LEAF node then
4 Let be the function on CPSP defined by
5
6 return
7 else if is a FORGET VERTEX node with child then
8 TreeDP( )
9 foreach : CPSP do
10 Define by
11 projects to
12
13 return
14 else if is an INTRODUCE VERTEX node with child introducing vertex then
15 TreeDP( )
16 foreach : CPSP do
17 Define a function : CPSP
18 foreach do
19
20
21 return
22 else if is a JOIN node with children then
23 TreeDP( )
24 TreeDP( )
25 JoinComputationPLEP ( )
26 return
27 else if is an INTRODUCE EDGE node with child introducing edge then
28 TreeDP( )
29 Set as
30 Define by
31 .
32 JoinComputationPLEP ( )
33 return
34 return TreeDP( )
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
Algorithm 6 JoinComputationPLEP Path( )
Input: A set of vertices and two tables , indexed with all possible functions CPSP
Output: A table such that for any function : CPSP , the value is the probability that in a random realisation of , we have LDPL
1 For each : CPSP , set ;
2 for each pair of functions , : CPSP do
3 foreach do
4 Define : CPSP as follows:
5 ;
6 ,
6
7 return
path length function is , where is the table obtained as a result of the function call TreeDP(), the correctness of which is guaranteed using our induction hypothesis. Therefore for any realisation of such that , we can map it to a realisation of occurring with the same probability, differing only by the addition of a single isolated vertex . Note that such a map from realisations of to realisations of is surjective. Given that , we may construct the function such that in the following fashion: If the candidate path set projection contains a tuple which is a non-singleton tuple (i.e., ) and where we have for some then the longest disjoint path length of is , since is isolated. Otherwise, we use the image of the function on the candidate path set projection obtained from by restricting it to vertices of , i.e., removing the singleton tuple if it exists (noting that this has no effect on the maximal length of paths realising the candidate path set projection).
Case 3: is a Join node Let be a JOIN node with children and . Consider realisations of and , say and respectively, such that the functions and are known. Consider the union of and which we define by . Now, note that is a realisation of , the probabilistic graph associated with the node . By Claim C.10, we know how to express the function , the longest disjoint path length function of in the graph , from the functions and . Thus we can map pairs of realisations of and to realisations of , with the LDPL of the realisation of being determined from that of and . The resulting LDPL is computed by Algorithm 6 as prescribed by Claim C.10.
Case 4: b is an Introduce Edge node Algorithm 5 treats the addition of the new edge from to as taking a union of the graph under consideration with another graph with the same vertex set and with a single edge from to , all other vertices being isolated. For the latter graph, the probability distribution over longest disjoint path length functions of is trivially known and then we use Algorithm 6 like for the case of a JOIN node.
D Proofs for Section 6 (Intractable Cases on Treewidth-2 Probabilistic Graphs)
▶ Theorem 6.1. PLEP Path and PLEP Walk are #P-hard on probabilistic graphs of pathwidth 2.
Proof. We show this for PLEP Path and observe that the same reduction extends to PLEP Walk. We

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 .
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
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 of built on the set of variables , with terms of the form , where . We let be the number of variables of , and write for the number of satisfying assignments of , which is what we wish to compute. We construct the probabilistic graph described below (and illustrated in Figure 6).
Create a start vertex s.
Create vertices which will respectively correspond to the variables , and create vertices which will respectively correspond to the variables .
Create edges with probability 1 from to , from to , and so on, with the last such edge going from to .
Create a vertex u and an edge of probability 1 from to u.
Create paths of 2p edges with probability 1 from to , from to , and so on, with the last such path going from to .
For each vertex with , create an edge from to having probability .
For each vertex with , create an edge from to having probability .
Last, create two vertices and , and an edge from to having probability 1. Now, for each term of the formula with , construct a path from to of edges with probability 1 having length .
Observe that the graph thus constructed has treewidth at most 2. Indeed, the part of the graph comprising the vertex and the vertices with admits a path decomposition of width 2, as does the part of the graph comprising the vertices and the vertices with . To see this observe that we can define the node with the corresponding bag to contain the vertices . Connecting these nodes linearly to form a path gives a valid tree decomposition of the part of comprising and with . A similar construction works for the part of the graph comprising the vertex and the vertices with . Likewise, the part of the graph comprising , 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 . For every path of the form , we build a path decomposition by introducing nodes , where for the bag of is and the bag of is . These nodes are connected linearly to form a path, and the node is attached to the central node with bag . Repeating this construction for every 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 PLEP problem for the graph thus constructed, to compute the probability that there is a path of length exactly from to . We will return the value . To establish the correctness of this reduction we must show that , or in other words .
For this we define the function which maps every assignment of variables to a realisation of the probabilistic graph , where the edge from to is present if and only if is true, and the edge from to is present if and only if is true, and . Clearly is a bijection. We say that a realisation of is good if it contains a path of length exactly from to , and bad otherwise.
We then prove the following claim, which we denote by : the realisation is good if and only if is a satisfying assignment.
To prove the forward implication, suppose first that is a satisfying assignment. This implies that for some term of the , say , both variables and are made true by . Therefore the edges from to and from to must be present in . Therefore consider the path , which has length . Concatenate this with the edge joining and . Next concatenate it with the path , which has length . Lastly concatenate it with the edge from to , and then with the path of length from to corresponding to in the #PP2DNF formula.
The length of the path thus formed from to is then , i.e., .
We now show the reverse implication. Suppose a path of length exists. It must use exactly one path from to . Suppose it uses the path of length corresponding to a term . The path must take exactly one blue edge of the form and exactly one blue edge of the form , in addition to the edges and . One can see that the path length is then , that is, . By assumption this must be equal to . Now, subtracting 4 from both sides, and using the fact that we can consider the Euclidean division of each side of the equation by to conclude that and , so that we must have and . This implies that is a satisfying assignment since the term is satisfied.
Hence, this proves (†) 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 to 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 to t of length , and for each other desired length for some we create one edge from v to the right vertex of this path to also ensure that there is a path of length from v to 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 to 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 and having a path to 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 , for the intermediary vertices created on the long path, and finish by one bag . This concludes the proof.
E 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 , which implies the same for because both problems are equivalent.
We reduce from the #KNAPSACK problem. Consider an instance of #KNAPSACK with and a threshold . Let be the number of subsets such that , which is the number that we want to compute. From the instance , we construct the following probabilistic weighted graph as shown in Figure 2:
■ Create a source vertex and vertices corresponding to the integers .
■ For every , add an edge from to of weight and probability 1.
■ For every , create a vertex , create an edge of weight 1 and probability 1 from to , and create an edge of weight 1 and probability 1/2 from to .
It is easy to observe that has pathwidth 2, with a path decomposition featuring the bags . Further, we consider the following bijection between the set of subsets of and the set of realisations of the graph : each subset is mapped to the realisation of where the edge from to (shown in blue in Figure 2) does not appear if and only if . Let us say that a subset is good if its sum is no greater than , and bad otherwise. Let us further say that a realisation of is good if it has a path from to which
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
is no longer than , and bad otherwise. We will now show the following claim ( ): The set is good iff the realisation of is good. As the probability of each realisation of is , it is clear that ( ) implies that we can obtain the answer to the #KNAPSACK instance (i.e., the number of good subsets ) from the total probability of the good realisations of , simply by multiplying by . Hence, we show ( ) in what follows.
First, we show that for any , if is good then is good. Consider any set such that . Let the realisation be the image of under . Now consider the path described as follows: contains the vertices in that order (in addition to possibly some intermediate vertices). If then contains the edge of weight from to , else contains the path of length 2 via from to , edges of which exist in because . Observe now that the total weight of is , i.e., it is . Since , we have . Thus, is a good realisation.
Second, we show that for any , if is good then is good. So let and assume that the realisation of is good, i.e., that it has a path from to which has length less than or equal to . We assume without loss of generality that is a shortest path from to , so that it uses the path of length 2 between any two adjacent vertices and whenever it is present. Thus, the length of is . However, we know that has length . Thus, we have , so is good. Thus, we have established both directions of ( ).
Therefore if we have an oracle for the PLEP Walk problem, we use the oracle to compute the probability that there exists a path of length less than or equal to . Then gives the number of subsets of which sum to a value less than or equal to , for the given instance of #KNAPSACK, which concludes the reduction and establishes the result for PLEP Walk and PLEP Path.
We last explain how the proof can be modified to show the result for and . 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 where now appear with a probability .
Consider the map from subsets of the given set to realisations of in the proof above. Observe that a realisation of has a path of length greater than if and only if the preimage corresponding to it is a subset of which sums to a value greater than . In other words a subset which sums to a value less than or equal to maps to a realisation of which does not have a path of length at least .
Thus we call the oracle for the PLEP Walk problem to obtain the probability that there exists a path of length at least . Let be this probability. Then gives us the number of subsets of which sum to a value less than or equal to , concluding the reduction for PLEP Path and PLEP Walk.
▶ Proposition 7.4. For probabilistic weighted graphs of pathwidth 1, 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 and target , we construct the graph as follows, outlined in Figure 3.
Create a start vertex s
For every , create a vertex
For each vertex , create an edge of weight and probability from to
For each vertex , create an edge of weight and probability 1 from to s
Observe that has pathwidth 1. Now consider the problem of determining if a walk of length exists from to in this graph. Consider the obvious bijection between subsets of and realisations of , i.e., the edge from to is present in if and only if . We can immediately observe that contains a walk of length from to iff is feasible. Thus, the number of feasible subsets can be computed from the probability that contains a walk of length from to , by multiplying by . 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 and and a set of terms each of the form , we want to know the number of pairs formed of a subset of terms and of valuations of the variables such that evaluates to true under . Intuitively, this is like #PP2DNF except every satisfying Boolean valuation is counted as many times as there are subsets of terms whose disjunction satisfies . 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 of #WPP2DNF with terms built on the set of variables , , we construct an instance of #UBK as follows. We let be a list of integers that we define below. All integers are formed of 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-variable or Y-variable or a term, then a block of p bits coding the index of a X-variable, then a block of q bits coding the index of a Y-variable. The integers are as follows:
For every variable , we introduce in an integer . The binary representation of is given as follows, from most to least significant bit. The first bit is 1, and the next six bits are 000001. The next bits code the index of the variable in , i.e., the -th bit among these bits is 1 and all other bits are 0. The next bits are all 0 (they intuitively correspond to ).
For every variable , we introduce in an integer with binary representation given as follows. The first bit is 1, and the next six bits are 000100. The next bits (intuitively corresponding to ) are all 0. The next bits intuitively correspond to the set and code the index of the variable in , i.e., the -th bit among these bits is 1 and all other bits are 0.
For every term in we introduce in an integer with binary representation given as follows. The first bit is 1, and the next six bits are 010000. Then the -th bit of the next bits is 0 (coding ) and the others are 1, and then the -th bit of the next bits is 0 (coding ) 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 , whose binary representation comprises bits given as follows: the first two bits are 1, the next six bits are 010101 and the next 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 which maps every pair of an assignment of variables and a subset of terms to a set . The map is defined as follows. We have precisely when the variable is true in , we have precisely when the variable is true in , and we have precisely when is in . It is immediate that is a bijection between subsets of and pairs of a variable assignment and a subset of .
Next we show the following claim (†): we have that is a satisfying assignment of a subset of if and only if 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 counted for the #WPP2DNF instance, formed of a subset of terms of and an assignment which satisfies . Thus there exist and which are true under and are such that occurs in . Hence the integers occur in . Now, observe that . This shows that is a feasible subset of .
Path Length Existence Problems in Bounded-Treewidth Probabilistic Graphs
Now, in the backward direction, let be a feasible subset of . We show that must be a satisfying assignment of . Since is a feasible subset of , there exists a tuple of weights , such that , and only integers in have a nonzero weight in the tuple. We first claim that the tuple must consist of at most three integers, i.e., . This is because, looking at the two leading bits 11 of the target value, we know that every integer in has value 01 on the bits at this position (remembering that the integers in are one bit shorter than the target value). Thus, summing four or more of them, we would obtain a sum with at least bits, which would overshoot the target value .
Now, we know that there exists at most three integers in the set : we now show that there must be exactly three and that there must be one of the form , one of the form , and one of the form . Indeed, in the target value , 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 , 000100 for the , and 000001 for the . Thus, if two or three '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 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 (say for the variable ), exactly one of the integers corresponding to the set of variables (say for the variable ), 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 (for the term ). Indeed, if we consider the sum of the integers , only the position among the positions corresponding to the set of variables and the among the positions corresponding to the set of variables are 1 and the rest are 0. The target requires us to add to an integer that consists of 1 at all but these two positions. Thus, the third integer corresponding to a term is uniquely given by . Now since we must have that is a term of and that are true in , showing that is a valid assignment of . This establishes the backward direction of , so holds and the result is proven.