Skip to main content

Separation distance between two graphs

Source: R/metrics.R

Description

For every pair of nodes non-adjacent in cg2, picks a set separating them in cg2, and counts the pairs that set fails to separate in cg1. This measures how far cg1 is from satisfying the independences cg2 implies, in the way a constraint-based analysis would test them.

Usage

separation_distance(
  cg1,
  cg2,
  strategy = c("parents", "ancestors", "zl"),
  mb_enhanced = FALSE,
  symmetric = FALSE,
  normalized = FALSE
)

Arguments

cg1 The graph the separating sets are tested in.
cg2 The graph the separating sets are read off: a DAG, PDAG-family (PDAG, CPDAG, MPDAG), AG-family (AG, MAG), or PAG graph created with cgraph(), of the same kind as cg1 and with the same nodes.
strategy The separating set strategy for two DAGs: "parents" (default), "ancestors", or "zl". Not available for other classes.
mb_enhanced If TRUE, use Markov blankets as separating sets where possible.
symmetric If TRUE, average the distance over both directions.
normalized If TRUE, divide by the number of node pairs, n * (n - 1) / 2, giving a value in [0, 1].

Details

The separating set is picked by class:

DAG
By strategy: "parents" (the parents of both nodes), "ancestors" (their ancestors), or "zl" (a minimal separator, as minimal_separator()).
AG, MAG, PAG
A minimal separator.
PDAG, CPDAG, MPDAG
The possible parents of both nodes: their parents in any DAG consistent with cg2, which is invariant under Markov equivalence.

mb_enhanced = TRUE uses the Markov blanket of the first node instead wherever it separates them, which is often cheaper on sparse graphs.

Value

A number: the count of failed separations, or its share of all node pairs if normalized = TRUE.

References

Wahl J, Runge J (2025). “Separation-Based Distance Measures for Causal Graphs.” In Li Y, Mandt S, Agrawal S, Khan E (eds.), Proceedings of The 28th International Conference on Artificial Intelligence and Statistics, volume 258 of Proceedings of Machine Learning Research, 3412–3420. https://proceedings.mlr.press/v258/wahl25b.html.

Examples

cg1 <- cgraph(A %-->% B %-->% C, A %-->% C, C %-->% D)
cg2 <- cgraph(A %-->% B %-->% C %-->% D)
separation_distance(cg1, cg2)
#> [1] 1
separation_distance(cg1, cg2, strategy = "zl")
#> [1] 2
separation_distance(cg1, cg2, symmetric = TRUE)
#> [1] 0.5