Logo
pyagrum
  • Continuous Linear Gaussian Bayesian Networks
  • Learning a CLG
  • CLGLearner.Adjacency_search
Previous Next

CLGLearner.Adjacency_search

CLGLearner.Adjacency_search(order, verbose=False)

This function is the first step of PC-algo: Adjacency Search. Apply indep_test() to the first step of PC-algo for Adjacency Search.

Parameters:
  • order (list[int]) – A particular order of the Nodes.

  • verbose (bool) – Whether to print the process of Adjacency Search.

Return type:

tuple[dict[int, set[int]], dict[tuple[int, int], set[int]]]

Returns:

  • C (dict[int, set[int]]) – The temporary skeleton.

  • sepset (dict[tuple[int, int], set[int]]) – Sepset(which will be used in Step2&3 of PC-Algo).

Example

import pyagrum as gum
import pyagrum.clg as gclg

gum.initRandom(42)  # the draws of pyagrum.clg come from the random generator of aGrUM
clg = gclg.SEM.toclg("""
A = 0[1]
B = 2A[1]
C = -1.5B[1]
""")
gclg.ForwardSampling(clg).makeSample(2000).tocsv("data.csv")
learner = gclg.CLGLearner("data.csv")
skeleton, sepset = learner.Adjacency_search([0, 1, 2])
skeleton  # A-B-C: A and C are separated
# {0: {1}, 1: {0, 2}, 2: {1}}
sepset[(0, 2)]  # ... by B
# {1}

Class

CLGLearner


© Copyright 2018-2026, aGrUM/pyAgrum Team <info_at_agrum_dot_org> (pyAgrum re3.5.0). Last updated on Dec 04, 2026.

Built with Sphinx using a theme provided by Read the Docs.