PythonBNListener.setWhenNodeAdded

PythonBNListener.setWhenNodeAdded(pyfunc)

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

Parameters:

pyfunc (callable) – a function (id: int, name: str) called when the node is added

Raises:

pyagrum.InvalidArgument – if pyfunc is not callable

Return type:

None

Example

import pyagrum as gum

bn = gum.fastBN("A->B")
added = []
listener = bn.addStructureListener(whenNodeAdded=lambda i, name: added.append(name))
listener.setWhenNodeAdded(lambda i, name: added.append((i, name)))  # replaces the previous function
bn.add("C")
# 2
added
# [(2, 'C')]

Class

PythonBNListener