PythonBNListener.setWhenNodeDeleted

PythonBNListener.setWhenNodeDeleted(pyfunc)

Set the function called when a node is removed (it replaces the function previously set for this event on this listener).

Parameters:

pyfunc (callable) – a function (id: int) called when the node is removed

Raises:

pyagrum.InvalidArgument – if pyfunc is not callable

Return type:

None

Example

import pyagrum as gum

bn = gum.fastBN("A->B->C")
deleted = []
listener = bn.addStructureListener(whenNodeAdded=lambda i, name: None)
listener.setWhenNodeDeleted(lambda i: deleted.append(i))
bn.erase("B")
deleted
# [1]

Class

PythonBNListener