BayesNet.variables

BayesNet.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")
sorted(v.name() for v in bn.variables())
# ['A', 'B', 'C', 'D']
sorted(v.name() for v in bn.variables(["A", "C"]))
# ['A', 'C']
sorted(v.name() for v in bn.variables({bn.idFromName("B")}))
# ['B']

Class

BayesNet