tf_G.utils.callbacks

tf_G.utils.callbacks Module

It contains a set of classes that helps on notifications of graph changes.

UpdateEdgeListener

class tf_G.utils.callbacks.update_edge_listener.UpdateEdgeListener[source]

Listen notifications related with a change in graph edges.

The graph (or another class that wants to receive notifications from a edge change) inherits this class and when an edge changes it will receive notifications from the change in edge set of a graph.

The classes that inherit this class need to implement update_edge(edge,change) method.

update_edge(edge: numpy.ndarray, change: float)[source]

The callback to receive notifications about edge changes in the graph.

This method is called from the Graph when an addition or deletion is produced on the edge set. So probably is necessary to recompute the PageRank ranking.

Parameters:
  • edge (np.ndarray) – A 1-D np.ndarray that represents the edge that changes in the graph, where edge[0] is the source vertex, and edge[1] the destination vertex.
  • change (float) – The variation of the edge weight. If the final value is 0.0 then the edge is removed.
Returns:

This method returns nothing.

UpdateEdgeNotifier

class tf_G.utils.callbacks.update_edge_notifier.UpdateEdgeNotifier[source]

This class is used to notify another classes that a change in graph edges.

The graph (or another class that wants to notify an edge change) inherits this class and when an edge changes it will notify this change to all the attached objects.

The objects attached to this class need to implement update_edge(edge,change) method.

_listeners

set – The set of objects that will be notified when an edge modifies it weight.

__init__()[source]

Constructor of UpdateEdgeNotifier

The set of listeners is initialised.

attach(listener: tf_G.utils.callbacks.update_edge_listener.UpdateEdgeListener)[source]

Method to attach objects from this class notifications.

Parameters:listener (tf_G.UpdateEdgeListener) – An object that will start being notified when the graph changes its edge set.
Returns:This method returns nothing.
detach(listener: tf_G.utils.callbacks.update_edge_listener.UpdateEdgeListener)[source]

Method to detach objects from this clas notifications.

Parameters:listener (tf_G.UpdateEdgeListener) – An object that will stop being notified when the graph changes its edge set.
Returns:This method returns nothing.