JunctionTreeGenerator.binaryJoinTree

JunctionTreeGenerator.binaryJoinTree(*args)

Computes a binary join tree for its parameters: a join tree in which each clique has at most 3 neighbours. The elimination order is chosen by heuristics that take the domain sizes into account and, if given, the partial order.

Parameters:
  • g (pyagrum.UndiGraph) – an undirected graph: all the nodes are given the same domain size (2)

  • dag (pyagrum.DAG) – a DAG, triangulated through its moral graph: all the nodes are given the same domain size (2)

  • bn (pyagrum.BayesNet) – a Bayesian network, triangulated through its moral graph, with the domain sizes of its variables

  • mrf (pyagrum.MarkovRandomField) – a Markov random field, triangulated through its graph, with the domain sizes of its variables

  • partial_order (list[set[int | str]], optional) – a partition of all the nodes into an ordered list of sets: the nodes of the first set are eliminated first, then those of the second set, and so on. The nodes are given by their ids, or by their names for a Bayesian network or a Markov random field.

Raises:
  • pyagrum.NotFound – If the partial order does not contain all the nodes, or if a name is not the name of a variable.

  • pyagrum.InvalidArgument – If the partial order is not a sequence of sets of nodes.

Returns:

the binary join tree.

Return type:

pyagrum.CliqueGraph

Example

import pyagrum as gum

bn = gum.fastBN("A->D;B->D;C->D")
bjt = gum.JunctionTreeGenerator().binaryJoinTree(bn)
bjt.isJoinTree()
# True
max(len(bjt.neighbours(c)) for c in bjt.nodes()) <= 3  # each clique has at most 3 neighbours
# True

# a Markov random field is triangulated through its graph
mrf = gum.fastMRF("A--B--C;C--D;D--A")
gum.JunctionTreeGenerator().binaryJoinTree(mrf).isJoinTree()
# True

Class

JunctionTreeGenerator