PythonMRFListener.setWhenEdgeDeleted

PythonMRFListener.setWhenEdgeDeleted(pyfunc)

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

Parameters:

pyfunc (callable) – a function (i: int, j: int) called when the edge between i and j is removed (the order of i and j is not specified)

Raises:

pyagrum.InvalidArgument – if pyfunc is not callable

Return type:

None

Example

import pyagrum as gum

mrf = gum.fastMRF("A--B;B--C")
edges = []
listener = mrf.addStructureListener(whenNodeAdded=lambda i, name: None)
listener.setWhenEdgeDeleted(lambda i, j: edges.append({i, j}))  # the order of i and j is not specified
mrf.eraseFactor(["B", "C"])
edges
# [{1, 2}]

Class

PythonMRFListener