BayesNetFragment.variables

BayesNetFragment.variables(*args)

Return the variables of the model: all of them, or those corresponding to a list of names or to a set of node ids.

Parameters:

args (list[str] or set[int], optional) – variable names or node ids (all the variables of the model if absent)

Returns:

the corresponding variables

Return type:

set[pyagrum.DiscreteVariable]

Raises:

pyagrum.NotFound – If a name or an id is not the one of a variable of the model.

Example

import pyagrum as gum

bn = gum.fastBN("A->B->C;D")
fragment = gum.BayesNetFragment(bn)
fragment.installNode("A")
fragment.installNode("B")
sorted(v.name() for v in fragment.variables())
# ['A', 'B']
sorted(v.name() for v in fragment.variables(["B"]))
# ['B']

Class

BayesNetFragment