Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

ogdf::GraphObserver Class Referenceabstract

Abstract Base class for graph observers. More...

#include <ogdf/basic/Graph_d.h>

+ Inheritance diagram for ogdf::GraphObserver:

Public Member Functions

 GraphObserver ()=default
 Constructs instance of GraphObserver class. More...
 
 GraphObserver (const Graph *G)
 Constructs instance of GraphObserver class. More...
 
virtual void cleared ()=0
 Called by watched graph when its clear function is called, just before things are removed. More...
 
virtual void edgeAdded (edge e)=0
 Called by watched graph after an edge has been added. More...
 
virtual void edgeDeleted (edge e)=0
 Called by watched graph just before an edge is deleted. More...
 
const GraphgetGraph () const
 
virtual void nodeAdded (node v)=0
 Called by watched graph after a node has been added. More...
 
virtual void nodeDeleted (node v)=0
 Called by watched graph just before a node is deleted. More...
 
- Public Member Functions inherited from ogdf::Observer< Graph, GraphObserver >
 Observer ()=default
 Constructs instance of Observer class. More...
 
 Observer (const Observer &copy)=delete
 If you want to copy a subclass of Observer, call the default Observer() constructor and optionally also call reregister if it makes sense. More...
 
 Observer (Observer &&move)=delete
 If you want to move a subclass of Observer, call the default Observer() constructor and optionally also call reregister if it makes sense. More...
 
virtual ~Observer ()
 Destroys the instance, unregisters it from watched instance. More...
 
const GraphgetObserved () const
 
Observeroperator= (const Observer &copy)=delete
 
Observeroperator= (Observer &&move)=delete
 
virtual void registrationChanged (const Graph *old)
 Called after reregister() changed the observed instance. More...
 
void reregister (const Graph *obs)
 Associates observer instance with instance obs. More...
 

Detailed Description

Abstract Base class for graph observers.

If a class needs to keep track of changes in a graph like addition or deletion of nodes or edges, you can derive it from GraphObserver and override the notification methods nodeDeleted, nodeAdded, edgeDeleted, edgeAdded and cleared.

It is guaranteed that the Graph is in a valid state (in terms of Graph::consistencyCheck(), that means there are no-half added edges or the like) whenever the notification methods are called. Furthermore, on addition all registered Arrays have already been resized to accommodate the new object. On compound operations like Graph::split() or Graph::insert(), the notifications may be batched and thus delayed, that is, when the callback is made the Graph may already contain some further (fully initialized) nodes or edges for which the respective callbacks have not been called (but will be called right after).

Note that there are no callbacks for the reassignment of edge endpoints. Thus, Graph::split will be seen by a GraphObserver as the creation of an isolated node plus addition of a new edge to this node. Rerouting the split edge to the new node between those two callbacks will not be reported.

Definition at line 770 of file Graph_d.h.

Constructor & Destructor Documentation

◆ GraphObserver() [1/2]

ogdf::GraphObserver::GraphObserver ( )
default

Constructs instance of GraphObserver class.

◆ GraphObserver() [2/2]

ogdf::GraphObserver::GraphObserver ( const Graph G)
inlineexplicit

Constructs instance of GraphObserver class.

Parameters
Gis the graph to be watched

Definition at line 779 of file Graph_d.h.

Member Function Documentation

◆ cleared()

virtual void ogdf::GraphObserver::cleared ( )
pure virtual

Called by watched graph when its clear function is called, just before things are removed.

Implemented in ogdf::ClusterGraph, ogdf::sync_plan::PMatching, ogdf::sync_plan::QPartitioning, and ogdf::PlanRepInc.

◆ edgeAdded()

virtual void ogdf::GraphObserver::edgeAdded ( edge  e)
pure virtual

Called by watched graph after an edge has been added.

Implemented in ogdf::ClusterGraph, ogdf::sync_plan::PMatching, ogdf::sync_plan::QPartitioning, and ogdf::PlanRepInc.

◆ edgeDeleted()

virtual void ogdf::GraphObserver::edgeDeleted ( edge  e)
pure virtual

Called by watched graph just before an edge is deleted.

Implemented in ogdf::ClusterGraph, ogdf::sync_plan::PMatching, ogdf::sync_plan::QPartitioning, and ogdf::PlanRepInc.

◆ getGraph()

const Graph* ogdf::GraphObserver::getGraph ( ) const
inline

Definition at line 796 of file Graph_d.h.

◆ nodeAdded()

virtual void ogdf::GraphObserver::nodeAdded ( node  v)
pure virtual

Called by watched graph after a node has been added.

Implemented in ogdf::ClusterGraph, ogdf::sync_plan::PMatching, ogdf::sync_plan::QPartitioning, and ogdf::PlanRepInc.

◆ nodeDeleted()

virtual void ogdf::GraphObserver::nodeDeleted ( node  v)
pure virtual

Called by watched graph just before a node is deleted.

Implemented in ogdf::ClusterGraph, ogdf::sync_plan::PMatching, ogdf::sync_plan::QPartitioning, and ogdf::PlanRepInc.


The documentation for this class was generated from the following file: