arXiv:2610.30291cs.LGOct 2026

Manuscript Offprint

arXiv:2610.30291

Generalizing Metropolis-Hastings for DAG Sampling

Daniele Nikzad, Mikko Koivisto

Abstract

A fundamental challenge in Bayesian network structure learning lies in efficiently approximating the posterior distribution of directed acyclic graphs (DAGs). For large, high-dimensional datasets, the task remains beyond the capabilities of current methods. This work advances Markov chain Monte Carlo algorithms by introducing novel moves that simultaneously resample the parents for multiple nodes of the DAG. At the core of these moves is duet sampling, a new generalization of the Metropolis–Hastings algorithm that selects two proposal distributions from a pool at each iteration. One is used for generating a candidate state of the Markov chain and another for evaluating the return to the current state; both are ingredients of an appropriately crafted acceptance criterion. Pairing different proposal distributions provides additional freedom and enables constructing Markov chains that mix more efficiently than their basic Metropolis–Hastings counterparts, at no additional computational cost. Experiments show that our new moves, both individually and in combination, outperform the previous state of the art, which relies on a more restrictive pool of moves. This advantage persists even when letting the previous methods leverage duet sampling to enhance their performance.

Keywords: acceptance criteria, algorithms, Bayesian networks, Markov chain Monte Carlo, scalability.

1 Introduction

Given the pivotal role of directed acyclic graphs (DAGs) in capturing conditional independencies (Pearl, 1988; Koller and Friedman, 2009) and causal structures (Pearl, 2009), substantial research effort has been devoted to learning DAG models from data. Since the seminal studies by Buntine (1991), Cooper and Herskovits (1992), and Madigan and Raftery (1994), the Bayesian paradigm for statistical inference has become one of the most extensively explored approaches to learning. The Bayesian approach is particularly appealing because it provides a principled formalism for expressing uncertainties about any involved unknowns both before and after seeing the data, by prior and posterior probabilities, respectively (Heckerman et al., 1995).

Computationally, constructing DAGs that accurately represent the posterior distribution has proven to be very demanding. Even finding a single posterior mode is NP-hard (Chickering, 1996), the known exact algorithms being feasible only up to around 30 nodes (Koivisto and Sood, 2004; Silander and Myllymäki, 2006; Yuan and Malone, 2013) or, in

©2026 Daniele Nikzad and Mikko Koivisto.

License: CC-BY 4.0, see https://creativecommons.org/licenses/by/4.0/.

some favorable cases, up to around a hundred of nodes (Bartlett and Cussens, 2017). To tackle larger networks, various search heuristics have been explored, without optimality guarantees (Kitson et al., 2023). As constructing the full DAG posterior is feasible only for DAGs on five or fewer nodes, moderately exponential exact algorithms have been developed to compute low-dimensional marginals, such as edge and ancestor relation probabilities (Koivisto and Sood, 2004; Koivisto, 2006; Pensar et al., 2020; Tian and He, 2009), as well as to sampling DAGs from the posterior (Harviainen and Koivisto, 2024; He et al., 2016; Talvitie et al., 2020). These algorithms are practical up to around 25 nodes. For Bayesian learning of larger DAGs, research has focused on two computational paradigms: Markov chain Monte Carlo (MCMC) methods, which are guaranteed to yield accurate approximations if run long enough (e.g., Friedman and Koller, 2003; Goudie and Mukherjee, 2016; Grzegorczyk and Husmeier, 2008; Niinimäki et al., 2016; Nikzad et al., 2026; Su and Borsuk, 2016; Viinikka et al., 2020), and variational methods that aim to find an optimal proxy posterior in some simplified class of distributions (Annadani et al., 2023; Cundy et al., 2021; Lorch et al., 2021).

Recent work (Nikzad et al., 2026) suggests that the most promising approach to approximate the posterior of larger networks is MCMC on the natural DAG space. Specifically, the work gives highly efficient implementations both for basic single-edge moves (Madigan and York, 1995; Giudici and Castelo, 2003) and for advanced moves that simultaneously resample the parents of two adjacent nodes (Grzegorczyk and Husmeier, 2008) or of a node and its children (Su and Borsuk, 2016). For the latter move types, the key new discovery is a pruning technique that enables discarding possible parent sets as preprocessing, often significantly reducing the computations per parent set update during the Markov chain simulation. The presented algorithm, Gibby, was shown to outperform other approaches: MCMC on a node partition space (BiDAG, Kuipers and Moffa, 2017; Suter et al., 2023), variational inference in a “continuous DAG space” (DiBS, Lorch et al., 2021), and generative flow networks (DAG-GFlowNet, Deleu et al., 2022). However, Gibby also inherits a major weakness of the implemented moves: even when resampling entire parent sets, the moves are constrained to preserve certain adjacencies in the local structure. Another promising option is the blocked Gibbs (BG) move of Goudie and Mukherjee (2016), which resamples the parents for a few randomly selected nodes from their joint full conditional posterior, making so effective use of the local posterior and yielding an efficiently mixing Markov chain. The computational cost of the BG move can likewise be reduced by leveraging the pruning technique of Nikzad et al. (2026). Nevertheless, the computations quickly become prohibitively expensive, unless the block size and the number of parents per node are bounded by small constants.

Motivated by the limitations of existing moves, we ask: Are there other types of moves that enable even more flexible jumps to high-posterior DAGs without compromising computational efficiency?

We will answer this question in the affirmative by introducing novel moves that simultaneously update the parent sets of multiple nodes. Our moves are motivated by two lines of previous work and thus can be divided into two broad classes. First, we study a move that resamples the parents for a random pair of nodes, such that the edge between the nodes is added, removed, or reversed, depending on their current adjacency. This edge-constrained (EC) move extends both the single-edge moves by Giudici and Castelo

(2003) and the edge reversal move by Grzegorczyk and Husmeier (2008). We also present a variant, the ancestor-constrained (AC) move, which imposes constraints on the ancestor relation rather than direct adjacency between the two nodes. The second class of moves is inspired by the BG move. Like BG, our unconstrained sequential resampling (USR) move samples blocks of parent sets for multiple nodes without imposing any constraints other than acyclicity. However, it generates the parent sets sequentially rather than jointly, which significantly reduces the computational cost. In return, a USR move may reject the proposal. We mitigate this shortcoming by leveraging a novel MCMC algorithm that can favor long jumps in the DAG space.

Indeed, the success of the new USR move relies on a generalization of the Metropolis–Hastings (MH) algorithm that, we believe, is of independent interest. The standard MH algorithm (Hastings, 1970; Tierney, 1994) uses an acceptance ratio that applies the same proposal distribution in two directions: from the current state to the proposed state, and vice versa. Our generalization, which we call duet sampling, employs two proposal distributions: one in the forward direction and another in the reverse direction. By using a suitable acceptance criterion, we obtain a reversible Markov chain. The added flexibility allows us to choose pairings of proposal distributions that enhance the mixing properties of the Markov chain. This turns out to be crucial for the efficiency of the USR move, which would perform substantially worse if implemented under the standard Metropolis–Hastings algorithm; we also observe duet sampling to yield a notable gain in (our implementation of) the Markov blanket resampling move of Su and Borsuk (2016). Also the EC and AC moves are naturally written in terms of duet sampling.

The rest of this article is organized as follows. Section 2 introduces the Bayesian approach to learning Bayesian networks and reviews previous algorithms based on simulating Markov chains over the space of DAGs. Section 3 gives the formulation of duet sampling, along with two particular ways to pair proposal distributions: independently at random and deterministically. Section 4 presents the new moves, AC, EC, and USR, with concrete instantiations of the two classes of pairings. Section 5 is dedicated to empirical studies: focusing primarily on large, high-dimensional datasets, we highlight the limitations of previous algorithms and the consistent superiority of our new algorithms. Section 6 concludes and points to directions for future research. We have relegated to the appendix routine proofs and additional analyses that, while likely of secondary interest, are essential for completeness.

References (38)