PythonMRFListener.setWhenNodeAdded

PythonMRFListener.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

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

Class

PythonMRFListener