PythonBNListener.setWhenArcDeleted
- PythonBNListener.setWhenArcDeleted(pyfunc)
Set the function called when an arc is removed (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 removed- Raises:
pyagrum.InvalidArgument – if
pyfuncis 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.setWhenArcDeleted(lambda tail, head: arcs.append((tail, head)))
bn.eraseArc("A", "B")
arcs
# [(0, 1)]
bn.erase("C") # the arcs of a removed node are removed first
arcs
# [(0, 1), (1, 2)]
Class