PythonBNListener.setWhenArcAdded

PythonBNListener.setWhenArcAdded(pyfunc)

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

Parameters:

pyfunc (callable) – a function (tail: int, head: int) called when the arc (tail, head) is added

Raises:

pyagrum.InvalidArgument – if pyfunc is not callable

Return type:

None

Example

import pyagrum as gum

bn = gum.fastBN("A->B;C")
arcs = []
listener = bn.addStructureListener(whenNodeAdded=lambda i, name: None)
listener.setWhenArcAdded(lambda tail, head: arcs.append((tail, head)))
bn.addArc("B", "C")
arcs
# [(1, 2)]

Class

PythonBNListener