The Tulip library can also manage subgraphs. By definition a subgraph G' of a graph G is part (subset) of the elements of G such that G' is also a graph (all sources and targets of the edges of G' must be in G'). As a subgraph is also a graph it can itself contain subgraphs. In such a hierarchy, if a graph G" is a descendant of a graph G, G" is also a subgraph of G.
One of the strong point of Tulip is to ensure efficiently that all elements are shared between graphs in a hierarchy of graphs. Thus, if a node n is an element of a graph G and of a graph G', the entity n is the same in both graphs. Of course, the parameters of the entity can change between graphs. For instance, the degree of n can be smaller for a subgraph, as it can have less edges.
The subgraph relation in the hierarchy is preserved when one modifies a graph. This means that if one adds a node to a graph, this node is automatically added to all its ancestors as well. If one deletes a node, this node is automatically deleted from all the descendants of the graph. If one reverses an edge, this edge is reversed in all the graphs of the hierarchy.
In order to manipulate a hierarchy of graphs, more functions have been added to those introduced above. They provide navigation and modification for the hierarchy. The access to the hierarchy is provided by iterators, which are not persistent and thus, if the hierarchy is modified, the iterators are invalid.
List of available modification operations
Graph *addSubGraph()
: returns an empty subgraph of this graph.
Graph *delSubGraph(Graph *)
: deletes a subgraph. Its descendants
continue to be descendants of this graph.
Graph *delAllSubGraph(Graph *)
: deletes a subgraph and all its descendants.
edge addEdge(edge)
: adds an edge element from another graph in the hierarchy.
void addNode(node)
: adds a node element from another graph in the hierarchy.
List of available access operations
Iterator * getSubGraphs()
: returns an iterator on the subgraphs.
Graph * getSuperGraph()
: returns the parent of the graph. If the graph has
no parent, it returns the graph itself.