BayesNetFragment.ancestors

BayesNetFragment.ancestors(*args)

give the set of nodeid of ancestors of a node

Parameters:

norid (int | str) – the name or the id of the node

Returns:

the set of ids of the ancestors of node norid.

Return type:

set

Example

import pyagrum as gum

bn = gum.fastBN("A->B->C<-D;C->E")
fragment = gum.BayesNetFragment(bn)
fragment.installAscendants("C")  # A, B, C, D
fragment.ancestors("C")
# {0, 1, 3}

Class

BayesNetFragment