Tulip  5.7.4
Large graphs analysis and drawing
tlp::Graph Class Referenceabstract

#include <Graph.h>

+ Inheritance diagram for tlp::Graph:
+ Collaboration diagram for tlp::Graph:

Public Member Functions

virtual GraphaddCloneSubGraph (const std::string &name="unnamed", bool addSibling=false, bool addSiblingProperties=false)
 
virtual void addEdge (const edge e)=0
 
virtual edge addEdge (const node source, const node target)=0
 
void addEdges (const std::vector< edge > &edges)
 
virtual void addEdges (const std::vector< std::pair< node, node >> &edges)=0
 
virtual void addEdges (const std::vector< std::pair< node, node >> &edges, std::vector< edge > &addedEdges)=0
 
virtual void addEdges (Iterator< edge > *edges)=0
 
virtual void addLocalProperty (const std::string &name, PropertyInterface *prop)=0
 
virtual node addNode ()=0
 
virtual void addNode (const node n)=0
 
void addNodes (const std::vector< node > &nodes)
 
virtual void addNodes (Iterator< node > *nodes)=0
 
virtual void addNodes (unsigned int nbNodes)=0
 
virtual void addNodes (unsigned int nbNodes, std::vector< node > &addedNodes)=0
 
virtual GraphaddSubGraph (BooleanProperty *selection=nullptr, const std::string &name="unnamed")=0
 
GraphaddSubGraph (const std::string &name)
 
virtual const std::vector< edge > & allEdges (const node n) const =0
 
bool applyAlgorithm (const std::string &algorithm, std::string &errorMessage, DataSet *parameters=nullptr, PluginProgress *progress=nullptr)
 
bool applyPropertyAlgorithm (const std::string &algorithm, PropertyInterface *result, std::string &errorMessage, DataSet *parameters=nullptr, PluginProgress *progress=nullptr)
 
virtual Iterator< node > * bfs (const node root=node()) const =0
 
virtual bool canPop ()=0
 
virtual bool canPopThenUnpop ()=0
 
virtual bool canUnpop ()=0
 
virtual void clear ()=0
 
virtual node createMetaNode (const std::vector< node > &nodes, bool multiEdges=true, bool delAllEdge=true, bool allGrouped=true)
 
virtual node createMetaNode (Graph *subGraph, bool multiEdges=true, bool delAllEdge=true, bool allGrouped=true)
 
virtual void createMetaNodes (Iterator< Graph * > *itS, Graph *quotientGraph, std::vector< node > &metaNodes, bool inoutGrouped=true)
 
virtual unsigned int deg (const node n) const =0
 
virtual void delAllSubGraphs (Graph *graph=nullptr)=0
 
virtual void delEdge (const edge e, bool deleteInAllGraphs=false)=0
 
void delEdges (const std::vector< edge > &edges, bool deleteInAllGraphs=false)
 
virtual void delEdges (Iterator< edge > *itE, bool deleteInAllGraphs=false)=0
 
virtual void delLocalProperty (const std::string &name)=0
 
virtual void delNode (const node n, bool deleteInAllGraphs=false)=0
 
void delNodes (const std::vector< node > &nodes, bool deleteInAllGraphs=false)
 
virtual void delNodes (Iterator< node > *it, bool deleteInAllGraphs=false)=0
 
virtual Iterator< node > * dfs (const node root=node()) const =0
 
virtual unsigned int edgePos (const edge e) const =0
 
virtual const std::vector< edge > & edges () const =0
 
virtual const std::pair< node, node > & ends (const edge e) const =0
 
bool existAttribute (const std::string &name) const
 
virtual edge existEdge (const node source, const node target, bool directed=true) const =0
 
virtual bool existLocalProperty (const std::string &name) const =0
 
virtual bool existProperty (const std::string &name) const =0
 
DataTypegetAttribute (const std::string &name) const
 
template<typename ATTRIBUTETYPE >
bool getAttribute (const std::string &name, ATTRIBUTETYPE &value) const
 
const DataSetgetAttributes () const
 
virtual GraphgetDescendantGraph (const std::string &name) const =0
 
virtual GraphgetDescendantGraph (unsigned int id) const =0
 
Iterator< Graph * > * getDescendantGraphs () const
 
virtual Iterator< edge > * getEdgeMetaInfo (const edge metaEdge) const =0
 
virtual Iterator< edge > * getEdges () const =0
 
virtual std::vector< edgegetEdges (const node source, const node target, bool directed=true) const =0
 
unsigned int getId () const
 
virtual Iterator< edge > * getInEdges (const node n) const =0
 
virtual Iterator< PropertyInterface * > * getInheritedObjectProperties () const =0
 
virtual Iterator< std::string > * getInheritedProperties () const =0
 
virtual node getInNode (const node n, unsigned int i) const =0
 
virtual Iterator< node > * getInNodes (const node n) const =0
 
virtual Iterator< edge > * getInOutEdges (const node n) const =0
 
virtual Iterator< node > * getInOutNodes (const node n) const =0
 
virtual Iterator< PropertyInterface * > * getLocalObjectProperties () const =0
 
virtual Iterator< std::string > * getLocalProperties () const =0
 
template<typename PropertyType >
PropertyType * getLocalProperty (const std::string &name)
 
PropertyInterfacegetLocalProperty (const std::string &propertyName, const std::string &propertyType)
 
virtual std::string getName () const =0
 
virtual GraphgetNodeMetaInfo (const node metaNode) const =0
 
virtual Iterator< node > * getNodes () const =0
 
virtual GraphgetNthSubGraph (unsigned int n) const
 
virtual Iterator< PropertyInterface * > * getObjectProperties () const =0
 
virtual edge getOneEdge () const =0
 
virtual node getOneNode () const =0
 
virtual Iterator< edge > * getOutEdges (const node n) const =0
 
virtual node getOutNode (const node n, unsigned int i) const =0
 
virtual Iterator< node > * getOutNodes (const node n) const =0
 
virtual Iterator< std::string > * getProperties () const =0
 
template<typename PropertyType >
PropertyType * getProperty (const std::string &name)
 
virtual PropertyInterfacegetProperty (const std::string &name) const =0
 
PropertyInterfacegetProperty (const std::string &propertyName, const std::string &propertyType)
 
virtual edge getRandomEdge () const =0
 
virtual node getRandomNode () const =0
 
virtual GraphgetRoot () const =0
 
virtual tlp::node getSink () const
 
virtual tlp::node getSource () const
 
virtual GraphgetSubGraph (const std::string &name) const =0
 
virtual GraphgetSubGraph (unsigned int id) const =0
 
virtual Iterator< Graph * > * getSubGraphs () const =0
 
virtual GraphgetSuperGraph () const =0
 
virtual bool hasEdge (const node source, const node target, bool directed=true) const
 
virtual unsigned int indeg (const node n) const =0
 
GraphinducedSubGraph (BooleanProperty *selection, Graph *parentSubGraph=nullptr, const std::string &name="unnamed")
 
GraphinducedSubGraph (const std::vector< node > &nodes, Graph *parentSubGraph=nullptr, const std::string &name="unnamed")
 
virtual bool isDescendantGraph (const Graph *subGraph) const =0
 
virtual bool isElement (const edge e) const =0
 
virtual bool isElement (const node n) const =0
 
virtual bool isEmpty () const
 
virtual bool isMetaEdge (const edge e) const =0
 
virtual bool isMetaNode (const node n) const =0
 
virtual bool isSubGraph (const Graph *subGraph) const =0
 
virtual unsigned int nodePos (const node n) const =0
 
virtual const std::vector< node > & nodes () const =0
 
virtual unsigned int numberOfDescendantGraphs () const =0
 
virtual unsigned int numberOfEdges () const =0
 
virtual unsigned int numberOfNodes () const =0
 
virtual unsigned int numberOfSubGraphs () const =0
 
void openMetaNode (node n, bool updateProperties=true)
 
virtual node opposite (const edge e, const node n) const =0
 
virtual unsigned int outdeg (const node n) const =0
 
virtual void pop (bool unpopAllowed=true)=0
 
virtual void popIfNoUpdates ()=0
 
virtual void push (bool unpopAllowed=true, std::vector< PropertyInterface * > *propertiesToPreserveOnPop=nullptr)=0
 
void removeAttribute (const std::string &name)
 
virtual void reserveEdges (unsigned int nbEdges)=0
 
virtual void reserveNodes (unsigned int nbNodes)=0
 
virtual void reverse (const edge e)=0
 
template<typename ATTRIBUTETYPE >
void setAttribute (const std::string &name, const ATTRIBUTETYPE &value)
 
void setAttribute (const std::string &name, const DataType *value)
 
virtual void setEdgeOrder (const node n, const std::vector< edge > &edges)=0
 
virtual void setEnds (const edge e, const node source, const node target)=0
 
virtual void setName (const std::string &name)=0
 
virtual void setSource (const edge e, const node source)=0
 
virtual void setSuperGraph (Graph *)=0
 
virtual void setTarget (const edge e, const node target)=0
 
virtual void sortElts ()=0
 
virtual node source (const edge e) const =0
 
virtual const std::vector< Graph * > & subGraphs () const =0
 
virtual void swapEdgeOrder (const node n, const edge e1, const edge e2)=0
 
virtual node target (const edge e) const =0
 
virtual void unpop ()=0
 
- Public Member Functions inherited from tlp::Observable
void addListener (Observable &listener) const
 
void addListener (Observable *const listener) const
 
void addObserver (Observable &observer) const
 
void addObserver (Observable *const observer) const
 
unsigned int countListeners () const
 
unsigned int countObservers () const
 
unsigned int getReceived () const
 
unsigned int getSent () const
 
void removeListener (Observable &listener) const
 
void removeListener (Observable *const listener) const
 
void removeObserver (Observable &observer) const
 
void removeObserver (Observable *const observer) const
 

Friends

class GraphAbstract
 
class GraphDecorator
 
class GraphUpdatesRecorder
 
class PropertyInterface
 
class PropertyManager
 

Additional Inherited Members

- Static Public Member Functions inherited from tlp::Observable
static void disableEventNotification ()
 
static void enableEventNotification ()
 
static tlp::node getNode (const tlp::Observable *obs)
 
static ObservablegetObject (tlp::node n)
 
static const tlp::VectorGraph & getObservableGraph ()
 
static unsigned int getScheduled (tlp::node n)
 
static void holdObservers ()
 
static bool isAlive (tlp::node n)
 
static unsigned int observersHoldCounter ()
 
static void unholdObservers ()
 
- Protected Member Functions inherited from tlp::Observable
 Observable (const Observable &)
 
bool hasOnlookers () const
 
void observableDeleted ()
 
Observableoperator= (const Observable &)
 
void sendEvent (const Event &message)
 
virtual void treatEvent (const Event &message)
 
virtual void treatEvents (const std::vector< Event > &events)
 

Detailed Description

The class Graph is the interface of a Graph in the Tulip Library.

There are a few principles to know when working with a Tulip Graph.

@chapter Directed Every edge is directed in a Tulip Graph. You can choose to ignore this, but every edge has a source and destination.

@chapter Inheritance

Subgraphs inherit from their parent graph. This is true of nodes and edges; every node and edge in a subgraph also exists in each of its parent graphs. This is also true of properties; every property in a graph exist in all of its subgraphs, except if it has been replaced by a local property.

For instance, if you have the following graph hierarchy: root / \ A B

Every node in A is in root, and every node in B is in root. Nodes can be in A and root but not B; or in B and root but not A.

For instance, imagine a graph. You want to compare it to its Delaunay triangulation. You need to create a subgraph that is a clone of the original (say this is A) to keep the original graph, and another copy (say this one is B) on which you will perform the delaunay triangulation.

B will have none of the original edges, and A will have only the original edges.

As for properties; let's imagine the same graph hierarchy. You want to compare two different layouts on the same graph. You need to create two clone subgraphs, on each you make the 'viewLayout' property local. This results in A and B having different values for the layout, but everything else in common. You then can apply two different algorithms on A and B (e.g. Bubble Tree and Tree Radial).

@chapter Meta Nodes A meta node is a node representing a subgraph of the current graph.

@chapter Undo Redo The Tulip Graph object supports for undo and redo of modifications. The operations affect the whole graph hierarchy, and cannot be limited to a subgraph.

Definition at line 234 of file Graph.h.

Member Function Documentation

◆ addCloneSubGraph()

virtual Graph* tlp::Graph::addCloneSubGraph ( const std::string &  name = "unnamed",
bool  addSibling = false,
bool  addSiblingProperties = false 
)
virtual

Creates and returns a subgraph that contains all the elements of this graph.

Parameters
nameThe name of the newly created subgraph. Defaults to "unnamed".
addSiblingif true the clone subgraph will be a sibling of this graph, if false (the default) it will be a subgraph of this graph
addSiblingPropertiesif true the local properties will be cloned into the sibling of this graph, if false (the default) the local properties will not be cloned
Returns
:Graph* The newly created clone subgraph. nullptr will be returned if addSibling is set to true and this graph is a root graph.

◆ addEdge() [1/2]

virtual void tlp::Graph::addEdge ( const edge  e)
pure virtual

Adds an existing edge in the graph. This edge is also added in all the ancestor graphs. The edge must be an element of the graph hierarchy, thus it must be an element of the root graph.

Warning
Using this method on the root graph will display a warning on the console.
Parameters
eThe edge to add to this subgraph.
See also
addEgdes() to add more than one edge at once.
addNode() to add nodes.

◆ addEdge() [2/2]

virtual edge tlp::Graph::addEdge ( const node  source,
const node  target 
)
pure virtual

Adds a new edge in the graph This edge is also added in all the super-graph of the graph.

Parameters
sourceThe source of the edge.
targetThe target of the edge.
Returns
The newly added edge.
See also
addEdges() to add multiple edges at once.

◆ addEdges() [1/4]

void tlp::Graph::addEdges ( const std::vector< edge > &  edges)

Adds existing edges in the graph. The edges are also added in all the ancestor graphs. The added edges must be elements of the graph hierarchy, thus they must be elements of the root graph.

Warning
Using this method on the root graph will display a warning on the console.
Parameters
edgesa vector of the edges to add on this subgraph.

◆ addEdges() [2/4]

virtual void tlp::Graph::addEdges ( const std::vector< std::pair< node, node >> &  edges)
pure virtual

Adds new edges in the graph. The new edges are also added in all graph ancestors.

Warning
If the edges vector contains a node that does not belong to this graph, undefined behavior will ensue.
Parameters
edgesA vector describing between which nodes to add edges. The first element of the pair is the source, the second is the destination.

◆ addEdges() [3/4]

virtual void tlp::Graph::addEdges ( const std::vector< std::pair< node, node >> &  edges,
std::vector< edge > &  addedEdges 
)
pure virtual

Adds new edges in the graph and returns them in the addedEdges vector. The new edges are also added in all graph ancestors.

Warning
If the edges vector contains a node that does not belong to this graph, undefined behavior will ensue.
Parameters
edgesA vector describing between which nodes to add edges. The first element of the pair is the source, the second is the destination.
addedEdgesThe newly added edges. This vector is cleared before being filled.

◆ addEdges() [4/4]

virtual void tlp::Graph::addEdges ( Iterator< edge > *  edges)
pure virtual

Adds existing edges in the graph. The edges are also added in all the ancestor graphs. The added edges must be elements of the graph hierarchy, thus they must be elements of the root graph.

Warning
Using this method on the root graph will display a warning on the console.
The graph does not take ownership of the iterator.
Parameters
edgesThe edges to add on this subgraph.

◆ addLocalProperty()

virtual void tlp::Graph::addLocalProperty ( const std::string &  name,
PropertyInterface prop 
)
pure virtual

Adds a property to the graph. The graph takes ownership of the property. If you want to delete it, use Graph::delLocalProperty().

Parameters
nameThe unique identifier of the property.
propThe property to add.

◆ addNode() [1/2]

virtual node tlp::Graph::addNode ( )
pure virtual

Adds a new node in the graph and returns it. This node is also added in all the ancestor graphs.

Returns
The newly added node.
See also
addNodes() if you want to add more than one node.

◆ addNode() [2/2]

virtual void tlp::Graph::addNode ( const node  n)
pure virtual

Adds an existing node in the graph. This node is also added in all the ancestor graphs. This node must exists in the graph hierarchy (which means it must exist in the root graph). You cannot add a node to the root graph this way (as it must already be an element of the root graph).

Warning
Using this method on the root graph will display a warning on the console.
Parameters
nThe node to add to a subgraph. This node must exist in the root graph.
See also
addNode() to add a new node to a graph.

◆ addNodes() [1/4]

void tlp::Graph::addNodes ( const std::vector< node > &  nodes)

Adds existing nodes in the graph. The nodes are also added in all the ancestor graphs. as with addNode(const tlp::node), the nodes must exist in the graph hierarchy and thus exist in the root graph, and nodes cannot be added this way to the root graph.

Warning
Using this method on the root graph will display a warning on the console.
Parameters
nodesa vector of nodes to add to this subgraph.

◆ addNodes() [2/4]

virtual void tlp::Graph::addNodes ( Iterator< node > *  nodes)
pure virtual

Adds existing nodes in the graph. The nodes are also added in all the ancestor graphs. as with addNode(const tlp::node), the nodes must exist in the graph hierarchy and thus exist in the root graph, and node cannot be added this way to the root graph.

Warning
Using this method on the root graph will display a warning on the console.
The graph does not take ownership of the Iterator.
Parameters
nodesAn iterator over nodes to add to this subgraph. The graph does not takes ownership of this iterator.

◆ addNodes() [3/4]

virtual void tlp::Graph::addNodes ( unsigned int  nbNodes)
pure virtual

Adds new nodes in the graph. The new nodes are also added in all the ancestor graphs.

Parameters
nbNodesThe number of nodes to add.
See also
addNode() to add a single node.

◆ addNodes() [4/4]

virtual void tlp::Graph::addNodes ( unsigned int  nbNodes,
std::vector< node > &  addedNodes 
)
pure virtual

Adds new nodes in the graph and returns them in the addedNodes vector. The new nodes are also added in all the ancestor graphs.

Parameters
nbNodesThe number of nodes to add.
addedNodesThe newly added nodes. This vector is cleared before being filled.
See also
addNode() to add a single node.

◆ addSubGraph() [1/2]

virtual Graph* tlp::Graph::addSubGraph ( BooleanProperty selection = nullptr,
const std::string &  name = "unnamed" 
)
pure virtual

Creates and returns a new subgraph of this graph.

If a BooleanProperty is provided, only nodes and edges for which it is true will be added to the subgraph. If none is provided, then the subgraph will be empty.

Parameters
selectionThe elements to add to the new subgraph. Defaults to nullptr.
nameThe name of the newly created subgraph. Defaults to "unnamed".
Returns
:Graph* The newly created subgraph.

◆ addSubGraph() [2/2]

Graph* tlp::Graph::addSubGraph ( const std::string &  name)

Creates and returns a new named subgraph of this graph.

Parameters
nameThe name of the newly created subgraph.
Returns
:Graph* The newly created subgraph.

◆ allEdges()

virtual const std::vector<edge>& tlp::Graph::allEdges ( const node  n) const
pure virtual

Gets all input/output edges of a node existing in the root graph.

Warning
If the current graph is not the root, the existence of the edge can be tested with isElement(edge) function.
Parameters
nThe node to get the input/output edges from.
Returns
a const reference to the vector of all edges of a node

◆ applyAlgorithm()

bool tlp::Graph::applyAlgorithm ( const std::string &  algorithm,
std::string &  errorMessage,
DataSet parameters = nullptr,
PluginProgress progress = nullptr 
)

Applies an algorithm plugin, identified by its name. Algorithm plugins are subclasses of the tlp::Algorithm interface. Parameters are transmitted to the algorithm through the DataSet. To determine a plugin's parameters, you can either:

  • refer to its documentation
  • use buildDefaultDataSet on the plugin object if you have an instance of it
  • call getPluginParameters() with the name of the plugin on the PluginLister

If an error occurs, a message describing the error should be stored in errorMessage.

Parameters
algorithmThe algorithm to apply.
errorMessageA string that will be modified to contain an error message if an error occurs.
parametersThe parameters of the algorithm. Defaults to nullptr.
progressA PluginProgress to report the progress of the operation, as well as the final state. Defaults to nullptr.
Returns
bool Whether the algorithm applied successfully or not. If not, check the error message.

◆ applyPropertyAlgorithm()

bool tlp::Graph::applyPropertyAlgorithm ( const std::string &  algorithm,
PropertyInterface result,
std::string &  errorMessage,
DataSet parameters = nullptr,
PluginProgress progress = nullptr 
)

Runs a plugin on the graph, whose result is a property.

Parameters
algorithmThe name of the plugin to run.
resultThe property in which to store the computed nodes/edges associated values. All previous values will be erased.
errorMessageStores the error message if the plugin fails.
parametersThe parameters of the algorithm. Some algorithms use this DataSet to output
progressA PluginProgress to report the progress of the operation, as well as the final state. Defaults to nullptr. some additional information.
Returns
Whether the plugin applied successfully or not. If not, check the error message.
See also
PluginLister::getPluginParameters() to retrieve the list of default parameters for the plugin.

◆ bfs()

virtual Iterator<node>* tlp::Graph::bfs ( const node  root = node()) const
pure virtual

Gets an iterator performing a breadth-first search on the graph.

Parameters
rootThe node from whom to start the BFS. If not provided, the root node will be assigned to a source node in the graph (node with input degree equals to 0). If there is no source node in the graph, a random node will be picked.
Returns
A stable iterator over the graph nodes in the BFS order.

◆ canPop()

virtual bool tlp::Graph::canPop ( )
pure virtual

Checks if there is a state to revert to.

Returns
Whether there was a previous call to push() that was not yet pop()'ed.

◆ canPopThenUnpop()

virtual bool tlp::Graph::canPopThenUnpop ( )
pure virtual

Checks if it is possible to call pop() and then unPop(), to undo then re-do modifications.

Returns
Whether it is possible to undo and then redo.

◆ canUnpop()

virtual bool tlp::Graph::canUnpop ( )
pure virtual

Checks if the last undone modifications can be redone.

Returns
Whether it is possible to re-do modifications that have been undone by pop().

◆ clear()

virtual void tlp::Graph::clear ( )
pure virtual

Removes all nodes, edges and subgraphs from this graph.

Contrarily to creating a new Graph, this keeps attributes and properties.

Returns
void

◆ createMetaNode() [1/2]

virtual node tlp::Graph::createMetaNode ( const std::vector< node > &  nodes,
bool  multiEdges = true,
bool  delAllEdge = true,
bool  allGrouped = true 
)
virtual

Creates a meta-node from a vector of nodes. Every edges from any node in the vector to another node of the graph will be replaced with meta edges from the meta node to the other nodes.

Warning
This method will fail when called on the root graph.
Parameters
nodesThe vector of nodes to put into the meta node.
multiEdgesWhether a meta edge should be created for each underlying edge.
delAllEdgeWhether the underlying edges will be removed from the whole hierarchy.
allGroupedIn the no multi edges case, indicates if the underlying edges will be grouped in a unique meta edge or in one for the in edges and one for the out edges.
Returns
The newly created meta node.

◆ createMetaNode() [2/2]

virtual node tlp::Graph::createMetaNode ( Graph subGraph,
bool  multiEdges = true,
bool  delAllEdge = true,
bool  allGrouped = true 
)
virtual

Closes an existing subgraph into a metanode. Edges from nodes in the subgraph to nodes outside the subgraph are replaced with edges from the metanode to the nodes outside the subgraph.

Warning
this method will fail when called on the root graph.
Parameters
subGraphan existing subgraph
multiEdgesindicates if a meta edge will be created for each underlying edge
delAllEdgeindicates if the underlying edges will be removed from the entire hierarchy
allGroupedIn the no multi edges case, indicates if the underlying edges will be grouped in a unique meta edge or in one for the in edges and one for the out edges.

◆ createMetaNodes()

virtual void tlp::Graph::createMetaNodes ( Iterator< Graph * > *  itS,
Graph quotientGraph,
std::vector< node > &  metaNodes,
bool  inoutGrouped = true 
)
virtual

Populates a quotient graph with one meta node for each iterated graph.

Parameters
itSa Graph iterator, (typically a subgraph iterator)
quotientGraphthe graph that will contain the meta nodes
metaNodeswill contains all the added meta nodes after the call
inoutGroupedindicates if the underlying edges will be grouped in distinct meta-edges according their direction.

◆ deg()

virtual unsigned int tlp::Graph::deg ( const node  n) const
pure virtual
Parameters
nThe node to get the degree of.
Returns
The degree of the given node.

◆ delAllSubGraphs()

virtual void tlp::Graph::delAllSubGraphs ( Graph graph = nullptr)
pure virtual

Deletes a subgraph of this graph. All subgraphs of the removed graph are re-parented to this graph. For instance, with a graph hierarchy as follows : root / \ A B /|\ C D E.

root->delSubGraph(B);
would result in the following hierarchy:
root
/ | \\
A C D E
@param graph The subgraph to delete.
@see delAllSubGraphs() if you want to remove all descendants of a graph.
/
virtual void delSubGraph(Graph *graph) = 0;
/**
* @brief Deletes a subgraph of this graph and all of its subgraphs.
* For instance, with a graph hierarchy as follows :
* root
* / \
* A B
* /|\
* C D E
*
* @codeline root->delSubGraph(B);
virtual void delAllSubGraphs(Graph *graph=nullptr)=0
Deletes a subgraph of this graph. All subgraphs of the removed graph are re-parented to this graph....

would result in the following hierarchy: root | A

Parameters
graphThe subgraph to delete.
See also
delSubGraph() if you want to keep the descendants of the subgraph to remove.

◆ delEdge()

virtual void tlp::Graph::delEdge ( const edge  e,
bool  deleteInAllGraphs = false 
)
pure virtual

Deletes an edge in the graph. The edge is also removed in the subgraphs hierarchy. The ordering of remaining edges is preserved.

Parameters
eThe edge to delete.
deleteInAllGraphsWhether to delete in all its parent graphs or only in this graph. By default only removes in the current graph.

◆ delEdges() [1/2]

void tlp::Graph::delEdges ( const std::vector< edge > &  edges,
bool  deleteInAllGraphs = false 
)

Deletes edges in the graph. These edges are also removed in the subgraphs hierarchy. The ordering of remaining edges is preserved.

Warning
The graph does not take ownership of the Iterator.
Parameters
edgesa vector of the edges to delete
deleteInAllGraphsWhether to delete in all its parent graphs or only in this graph. By default only removes in the current graph.

◆ delEdges() [2/2]

virtual void tlp::Graph::delEdges ( Iterator< edge > *  itE,
bool  deleteInAllGraphs = false 
)
pure virtual

Deletes edges in the graph. These edges are also removed in the subgraphs hierarchy. The ordering of remaining edges is preserved.

Warning
The graph does not take ownership of the Iterator.
Parameters
itE
deleteInAllGraphsWhether to delete in all its parent graphs or only in this graph. By default only removes in the current graph.

◆ delLocalProperty()

virtual void tlp::Graph::delLocalProperty ( const std::string &  name)
pure virtual

Removes and deletes a property from this graph. The property is removed from the graph's property pool, meaning its name can now be used by another property. The object is deleted and the memory freed.

Parameters
nameThe unique identifier of the property.

◆ delNode()

virtual void tlp::Graph::delNode ( const node  n,
bool  deleteInAllGraphs = false 
)
pure virtual

Deletes a node in the graph. This node is also removed in the subgraphs hierarchy of the current graph.

Parameters
nThe node to delete.
deleteInAllGraphsWhether to delete in all its parent graphs or only in this graph. By default only removes in the current graph.
See also
delNodes() to remove multiple nodes.

◆ delNodes() [1/2]

void tlp::Graph::delNodes ( const std::vector< node > &  nodes,
bool  deleteInAllGraphs = false 
)

Deletes nodes in the graph. These nodes are also removed in the subgraphs hierarchy of the current graph.

Warning
the graph does not take ownership of the Iterator.
Parameters
nodesa vector of the nodes to delete.
deleteInAllGraphsWhether to delete in all its parent graphs or only in this graph. By default only removes in the current graph.
See also
delNode() to remove a single node.

◆ delNodes() [2/2]

virtual void tlp::Graph::delNodes ( Iterator< node > *  it,
bool  deleteInAllGraphs = false 
)
pure virtual

Deletes nodes in the graph. These nodes are also removed in the subgraphs hierarchy of the current graph.

Warning
the graph does not take ownership of the Iterator.
Parameters
itThe nodes to delete.
deleteInAllGraphsWhether to delete in all its parent graphs or only in this graph. By default only removes in the current graph.
See also
delNode() to remove a single node.

◆ dfs()

virtual Iterator<node>* tlp::Graph::dfs ( const node  root = node()) const
pure virtual

Gets an iterator performing a depth-first search on the graph.

Parameters
rootThe node from whom to start the DFS. If not provided, the root node will be assigned to a source node in the graph (node with input degree equals to 0). If there is no source node in the graph, a random node will be picked.
Returns
A stable iterator over the graph nodes in the DFS order.

◆ edgePos()

virtual unsigned int tlp::Graph::edgePos ( const edge  e) const
pure virtual

Return the position of an edge in the vector of edges of the graph.

Parameters
eThe edge for which the position is requested

◆ edges()

virtual const std::vector<edge>& tlp::Graph::edges ( ) const
pure virtual

Return a const reference on the vector of edges of the graph It is the fastest way to access to edges, Iterators are 25% slower.

Remarks
o(1)
+ Here is the caller graph for this function:

◆ ends()

virtual const std::pair<node, node>& tlp::Graph::ends ( const edge  e) const
pure virtual

Gets the source and the target of an edge.

Parameters
eThe edge to get the ends of.
Returns
A pair whose first element is the source, and second is the target.

◆ existAttribute()

bool tlp::Graph::existAttribute ( const std::string &  name) const
inline

Checks if an attribute exists.

Parameters
nameThe name of the attribute to check for.
Returns
Whether the attribute exists.

Definition at line 1274 of file Graph.h.

◆ existEdge()

virtual edge tlp::Graph::existEdge ( const node  source,
const node  target,
bool  directed = true 
) const
pure virtual

Returns the first edge found between the two given nodes.

Warning
This function always returns an edge, you need to check if this edge is valid with edge::isValid().
Parameters
sourceThe source of the hypothetical edge.
targetThe target of the hypothetical edge.
directedWhen set to false an edge from target to source may also be returned
Returns
An edge that is only valid if it exists.

◆ existLocalProperty()

virtual bool tlp::Graph::existLocalProperty ( const std::string &  name) const
pure virtual

Checks if a property exists in this graph.

Parameters
Theunique identifier of the property.
Returns
Whether a property with the given name exists.

◆ existProperty()

virtual bool tlp::Graph::existProperty ( const std::string &  name) const
pure virtual

Checks if a property exists in this graph or one of its ancestors.

Parameters
Theunique identifier of the property.
Returns
Whether a property with the given name exists.

◆ getAttribute() [1/2]

DataType* tlp::Graph::getAttribute ( const std::string &  name) const

Gets a copy of the attribute.

Parameters
nameThe name of the attribute to retrieve.
Returns
A copy of the attribute to retrieve.

◆ getAttribute() [2/2]

template<typename ATTRIBUTETYPE >
bool tlp::Graph::getAttribute ( const std::string &  name,
ATTRIBUTETYPE &  value 
) const

Gets an attribute on the graph.

Parameters
nameThe name of the attribute to set.
valueThe value to set.
Returns
Whether the setting of the attribute was successful.

Definition at line 24 of file Graph.cxx.

+ Here is the call graph for this function:

◆ getAttributes()

const DataSet& tlp::Graph::getAttributes ( ) const
inline

Gets the attributes of the graph.

The attributes contains the name and any user-defined value.

Returns
The attributes of the graph.

Definition at line 1225 of file Graph.h.

+ Here is the caller graph for this function:

◆ getDescendantGraph() [1/2]

virtual Graph* tlp::Graph::getDescendantGraph ( const std::string &  name) const
pure virtual

Returns a pointer on the first descendant graph with the corresponding name or nullptr if there is no descendant graph with that name.

Parameters
nameThe name of the descendant graph to look for.
Returns
A graph named name, or nullptr if there is no such graph in this graph's descendants.
See also
getSubGraph(const std::string &) to search only in direct subgraphs.

◆ getDescendantGraph() [2/2]

virtual Graph* tlp::Graph::getDescendantGraph ( unsigned int  id) const
pure virtual

Returns a pointer on the descendant with the corresponding id or nullptr if there is no descendant with that id.

Parameters
idThe id of the descendant graph to retrieve.
Returns
A graph with the given id, or nullptr if no such graph exists in this graph's descendants.
See also
getSubGraph(unsigned int) to search only in direct subgraphs.

◆ getDescendantGraphs()

Iterator<Graph *>* tlp::Graph::getDescendantGraphs ( ) const

Gets an iterator over all the descendant subgraphs of the graph. For instance, in the following graph hierarchy: root / \ A B /|\ C D E.

@codeline root->getSubGraphs(); Will return an iterator over A B, C, D and E.

Returns
An iterator over this graph's descendant subgraphs.

◆ getEdgeMetaInfo()

virtual Iterator<edge>* tlp::Graph::getEdgeMetaInfo ( const edge  metaEdge) const
pure virtual

Gets an iterator over the edges composing a meta edge.

Parameters
metaEdgeThe metaEdge to get the real edges of.
Returns
An Iterator over the edges composing the metaEdge.
See also
getNodeMetaInfo()

◆ getEdges() [1/2]

virtual Iterator<edge>* tlp::Graph::getEdges ( ) const
pure virtual

Get an iterator over all the graph's edges.

Returns
An iterator over all the graph's edges.
See also
getInEdges()
getOutEdges()
getInOutEdges()
+ Here is the caller graph for this function:

◆ getEdges() [2/2]

virtual std::vector<edge> tlp::Graph::getEdges ( const node  source,
const node  target,
bool  directed = true 
) const
pure virtual

Returns all the edges between two nodes.

Parameters
sourceThe source of the hypothetical edges.
targetThe target of the hypothetical edges.
directedWhen set to false edges from target to source are also considered
Returns
a vector of existing edges

◆ getId()

unsigned int tlp::Graph::getId ( ) const
inline

Gets the unique identifier of the graph.

Returns
The unique identifier of this graph.

Definition at line 1067 of file Graph.h.

+ Here is the caller graph for this function:

◆ getInEdges()

virtual Iterator<edge>* tlp::Graph::getInEdges ( const node  n) const
pure virtual

Gets an iterator over the input edges of a node.

Parameters
nThe node to get the input edges from.
Returns
An iterator over the node's input edges.
See also
getEdges()
getOutEdges()
getInOutEdges()

◆ getInheritedObjectProperties()

virtual Iterator<PropertyInterface *>* tlp::Graph::getInheritedObjectProperties ( ) const
pure virtual

Gets an iterator over the properties inherited from this graph's ancestors, excluding this graph's local properties.

Returns
An iterator over the properties this graph inherited.

◆ getInheritedProperties()

virtual Iterator<std::string>* tlp::Graph::getInheritedProperties ( ) const
pure virtual

Gets an iterator over the names of the properties inherited from this graph's ancestors, excluding this graph's local properties.

Returns
An iterator over the names of the properties this graph inherited.

◆ getInNode()

virtual node tlp::Graph::getInNode ( const node  n,
unsigned int  i 
) const
pure virtual

Gets the i-th node in the input nodes of a given node. An input node 'in' of a node 'N' is the source of an edge going from 'in' to 'N'. e.g.

node in = graph->addNode();
node N = graph->addNode();
graph->addEdge(in, N);
//in == graph->getInNode(N, 1);

If you have 5 input nodes on a node N, then @codeline graph->getInNode(2); will return the second of those nodes. It will ignore the output nodes of this node.

Parameters
nThe node to get an input node of.
iThe index of the input node to get.
Returns
The i-th input node of the given node.
See also
getInNodes()
getInEdges()

◆ getInNodes()

virtual Iterator<node>* tlp::Graph::getInNodes ( const node  n) const
pure virtual

Gets an iterator over the input nodes of a node.

Parameters
nThe node to get the input nodes of.
Returns
An iterator over the input nodes of a node.
See also
getInNode()
getInOutNodes()
getInEdges()

◆ getInOutEdges()

virtual Iterator<edge>* tlp::Graph::getInOutEdges ( const node  n) const
pure virtual

Gets an iterator over the edges of a node.

Parameters
nThe node to get the edges from.
Returns
An iterator over the node's edges.
See also
getEdges()
getOutEdges()
getInEdges()

◆ getInOutNodes()

virtual Iterator<node>* tlp::Graph::getInOutNodes ( const node  n) const
pure virtual

Gets an iterator over the neighbors of a given node.

Parameters
nThe node to retrieve the neighbors of.
Returns
An iterator over the node's neighbors.

◆ getLocalObjectProperties()

virtual Iterator<PropertyInterface *>* tlp::Graph::getLocalObjectProperties ( ) const
pure virtual

Gets an iterator over the local properties of this graph.

Returns
An iterator over this graph's properties.

◆ getLocalProperties()

virtual Iterator<std::string>* tlp::Graph::getLocalProperties ( ) const
pure virtual

Gets an iterator over the names of the local properties of this graph.

Returns
An iterator over this graph's properties names.

◆ getLocalProperty() [1/2]

template<typename PropertyType >
PropertyType * tlp::Graph::getLocalProperty ( const std::string &  name)

Gets a property on this graph. The name of a property identifies it uniquely. Either there already exists a property with the given name, in which case it is returned. Either no such property exists and it is created.

The graph keeps ownership of the property, if you wish to remove it from the graph use Graph::delLocalProperty().

Warning
using the wrong template parameter will cause a segmentation fault.
Parameters
Theunique identifier of the property.
Returns
The property of given name.

Definition at line 37 of file Graph.cxx.

◆ getLocalProperty() [2/2]

PropertyInterface* tlp::Graph::getLocalProperty ( const std::string &  propertyName,
const std::string &  propertyType 
)

Gets a property on this graph, and this graph only. This forwards the call to the template version of getLocalProperty(), with the correct template parameter deduced from the propertyType parameter.

The graph keeps ownership of the property, if you wish to remove it from the graph use Graph::delLocalProperty().

Warning
using the wrong propertyType will result in a segmentation fault. Using an invalid property type will always return nullptr.
Parameters
propertyNameThe unique identifier of the property.
propertyTypeA string describing the type of the property.
Returns
The property of given name.
See also
getLocalProperty().

◆ getName()

virtual std::string tlp::Graph::getName ( ) const
pure virtual

Retrieves the name of the graph.

Returns
The name of the graph.

◆ getNodeMetaInfo()

virtual Graph* tlp::Graph::getNodeMetaInfo ( const node  metaNode) const
pure virtual

Gets the underlying graph of a meta node.

Parameters
metaNodeThe metanode.
Returns
The Graph pointed to by the metanode.
See also
getEdgeMetaInfo()

◆ getNodes()

virtual Iterator<node>* tlp::Graph::getNodes ( ) const
pure virtual

Gets an iterator over this graph's nodes.

Returns
An iterator over all the nodes of this graph.
See also
getInNodes()
getOutNodes()
getInOutNodes()
getEdges()

◆ getNthSubGraph()

virtual Graph* tlp::Graph::getNthSubGraph ( unsigned int  n) const
virtual

This method returns the nth subgraph. Since subgraphs order cannot be ensured in every implementation, this method should be equivalent to:

int i=0;
Iterator<Graph *> *it = g->getSubGraphs();
while (it->hasNext()) {
Graph *result = it->next();
if (i++ == n) {
delete it;
return result;
}
}
delete it;
return nullptr;
Parameters
nthe index of the subgraph to retrieve.
Returns
The n-th subgraph.

◆ getObjectProperties()

virtual Iterator<PropertyInterface *>* tlp::Graph::getObjectProperties ( ) const
pure virtual

Gets an iterator over the properties attached to this graph, whether they are local or inherited.

Returns
An iterator over all of the properties attached to this graph.

◆ getOneEdge()

virtual edge tlp::Graph::getOneEdge ( ) const
pure virtual

Returns the first edge in the graph.

◆ getOneNode()

virtual node tlp::Graph::getOneNode ( ) const
pure virtual

Returns the first node in the graph.

◆ getOutEdges()

virtual Iterator<edge>* tlp::Graph::getOutEdges ( const node  n) const
pure virtual

Gets an iterator over the output edges of a node.

Parameters
nThe node to get the output edges from.
Returns
An iterator over the node's output edges.
See also
getEdges()
getOutEdges()
getInOutEdges()

◆ getOutNode()

virtual node tlp::Graph::getOutNode ( const node  n,
unsigned int  i 
) const
pure virtual

Gets the i-th node in the output nodes of a given node. An output node 'out' of a node 'N' is the target of an edge going from 'N' to 'out'. e.g.

node N = graph->addNode();
node out = graph->addNode();
graph->addEdge(N, out);
//out == graph->getOutNode(N, 1);

If you have 5 output nodes on a node N, then @codeline graph->getOutNode(2); will return the second of those nodes. It will ignore the input nodes of this node.

Parameters
nThe node to get an output node of.
iThe index of the output node to get.
Returns
The i-th output node of the given node.
See also
getOutNodes()
getOutEdges()

◆ getOutNodes()

virtual Iterator<node>* tlp::Graph::getOutNodes ( const node  n) const
pure virtual

Gets an iterator over the output nodes of a node.

Parameters
nThe node to get the output nodes of.
Returns
An iterator over the output nodes of a node.
See also
getOutNode()
getInOutNodes()
getOutEdges()

◆ getProperties()

virtual Iterator<std::string>* tlp::Graph::getProperties ( ) const
pure virtual

Gets an iterator over the names of all the properties attached to this graph, whether they are local or inherited.

Returns
An iterator over the names of all the properties attached to this graph.

◆ getProperty() [1/3]

template<typename PropertyType >
PropertyType * tlp::Graph::getProperty ( const std::string &  name)

Gets a property on this graph or one of its ancestors. If the property already exists on the graph or in one of its ancestors, it is returned. Otherwise a new property is created on this graph.

The graph keeps ownership of the property, if you wish to remove it from the graph use Graph::delLocalProperty().

Warning
using the wrong propertyType will result in a segmentation fault. Using an invalid property type will always return nullptr.
Parameters
nameThe unique identifier of the property.
Returns
An existing property, or a new one if none exists with the given name.

Definition at line 50 of file Graph.cxx.

◆ getProperty() [2/3]

virtual PropertyInterface* tlp::Graph::getProperty ( const std::string &  name) const
pure virtual

Gets an existing property. In DEBUG mode an assertion checks the existence of the property.

The graph keeps ownership of the property, if you wish to remove it from the graph use Graph::delLocalProperty().

Parameters
nameThe unique identifier of the property.
Returns
An existing property, or nullptr if no property with the given name exists.

◆ getProperty() [3/3]

PropertyInterface* tlp::Graph::getProperty ( const std::string &  propertyName,
const std::string &  propertyType 
)

Gets a property on this graph or one of its ancestors. This forwards the call to the template version of getProperty(), with the correct template parameter deduced from the propertyType parameter.

The graph keeps ownership of the property, if you wish to remove it from the graph use Graph::delLocalProperty().

Warning
using the wrong propertyType will result in a segmentation fault. Using an invalid property type will always return nullptr.
Parameters
propertyNameThe unique identifier of the property.
propertyTypeA string describing the type of the property.
Returns
The property of given name.
See also
getProperty().

◆ getRandomEdge()

virtual edge tlp::Graph::getRandomEdge ( ) const
pure virtual

Returns a random edge in the graph.

Since
Tulip 4.8

◆ getRandomNode()

virtual node tlp::Graph::getRandomNode ( ) const
pure virtual

Returns a random node in the graph.

Since
Tulip 4.8

◆ getRoot()

virtual Graph* tlp::Graph::getRoot ( ) const
pure virtual

Gets the root graph of the graph hierarchy.

Returns
The root graph of the graph hierarchy.

◆ getSink()

virtual tlp::node tlp::Graph::getSink ( ) const
virtual

Finds the first node whose output degree equals 0.

Returns
tlp::node The first encountered node with output degree of 0, or an invalid node if none was found.

◆ getSource()

virtual tlp::node tlp::Graph::getSource ( ) const
virtual

Finds the first node whose input degree equals 0.

Returns
tlp::node The first encountered node with input degree of 0, or an invalid node if none was found.

◆ getSubGraph() [1/2]

virtual Graph* tlp::Graph::getSubGraph ( const std::string &  name) const
pure virtual

Returns a pointer on the subgraph with the corresponding name or nullptr if there is no subgraph with that name.

Parameters
nameThe name of the subgraph to retrieve.
Returns
A Graph named name, or nullptr if no such subgraph exists on this graph.
See also
getDescendantGraph(const std::string &) to search in the whole hierarchy.

◆ getSubGraph() [2/2]

virtual Graph* tlp::Graph::getSubGraph ( unsigned int  id) const
pure virtual

Returns a pointer on the subgraph with the corresponding id or nullptr if there is no subgraph with that id.

Parameters
idThe id of the subgraph to retrieve.
Returns
A subgraph of the given id, or null if no such subgraph exists on this graph.
See also
getDescendantGraph(unsigned int) to search in the whole hierarchy.

◆ getSubGraphs()

virtual Iterator<Graph *>* tlp::Graph::getSubGraphs ( ) const
pure virtual

Gets an iterator over all the subgraphs of the graph. For instance, in the following graph hierarchy: root / \ A B /|\ C D E.

@codeline root->getSubGraphs(); Will return an iterator over A and B, but not C, D and E.

Returns
An iterator over this graph's direct subgraphs.

◆ getSuperGraph()

virtual Graph* tlp::Graph::getSuperGraph ( ) const
pure virtual

Returns the parent of the graph. If called on the root graph, it returns itself.

Returns
The parent of this graph (or itself if it is the root graph).
See also
getRoot() to directly retrieve the root graph.

◆ hasEdge()

virtual bool tlp::Graph::hasEdge ( const node  source,
const node  target,
bool  directed = true 
) const
inlinevirtual

Checks if an edge exists between two given nodes.

Parameters
sourceThe source of the hypothetical edge.
targetThe target of the hypothetical edge.
directedWhen set to false edges from target to source are also considered
Returns
true if such an edge exists

Definition at line 1177 of file Graph.h.

◆ indeg()

virtual unsigned int tlp::Graph::indeg ( const node  n) const
pure virtual

Get the input degree of a node.

Parameters
nThe node to get the input degree of.
Returns
The input degree of the given node.

◆ inducedSubGraph() [1/2]

Graph* tlp::Graph::inducedSubGraph ( BooleanProperty selection,
Graph parentSubGraph = nullptr,
const std::string &  name = "unnamed" 
)

Creates and returns a new subgraph of the graph induced by a selection of nodes and edges.

Since
Tulip 4.10 Every node contained in the selection is added to the subgraph. Every edge and its source and target node contained in the selection is added to the subgraph. Every edge connecting any two nodes in the resulting set of nodes is also added.
Parameters
selectiona selection of nodes and edges.
parentSubGraphIf provided, is used as parent graph for the newly created subgraph instead of the graph this method is called on.
nameThe name of the newly created subgraph.
Returns
The newly created subgraph.

◆ inducedSubGraph() [2/2]

Graph* tlp::Graph::inducedSubGraph ( const std::vector< node > &  nodes,
Graph parentSubGraph = nullptr,
const std::string &  name = "unnamed" 
)

Creates and returns a new subgraph of the graph induced by a vector of nodes.

Since
Tulip 5.0 Every node contained in the given vector is added to the subgraph. Every edge connecting any two nodes in the set of given nodes is also added.
Parameters
nodesThe nodes to add to the subgraph. All the edges between these nodes are added too.
parentSubGraphIf provided, is used as parent graph for the newly created subgraph instead of the graph this method is called on.
nameThe name of the newly created subgraph.
Returns
The newly created subgraph.

◆ isDescendantGraph()

virtual bool tlp::Graph::isDescendantGraph ( const Graph subGraph) const
pure virtual

Indicates if the graph argument is a descendant of this graph.

Parameters
subGraphThe graph to check is a descendant of this graph.
Returns
Whether subGraph is a descendant of this graph.
See also
isSubGraph to search only in direct subgraphs.
+ Here is the caller graph for this function:

◆ isElement() [1/2]

virtual bool tlp::Graph::isElement ( const edge  e) const
pure virtual

Checks if an element belongs to this graph.

Parameters
eThe edge to check if it is an element of the graph.
Returns
Whether or not the element belongs to the graph.

◆ isElement() [2/2]

virtual bool tlp::Graph::isElement ( const node  n) const
pure virtual

Checks if an element belongs to this graph.

Parameters
nThe node to check if it is an element of the graph.
Returns
Whether or not the element belongs to the graph.

◆ isEmpty()

virtual bool tlp::Graph::isEmpty ( ) const
inlinevirtual

return whether the graph is empty or not.

Returns
true if the graph has no nodes, false if not.

Definition at line 1075 of file Graph.h.

◆ isMetaEdge()

virtual bool tlp::Graph::isMetaEdge ( const edge  e) const
pure virtual

Checks if an edge is a meta edge.

Parameters
eThe edge to check if it is a meta edge.
Returns
Whether or not the edge is a meta edge.

◆ isMetaNode()

virtual bool tlp::Graph::isMetaNode ( const node  n) const
pure virtual

Checks if a node is a meta node.

Parameters
nThe node to check if it is a meta node.
Returns
Whether or not the node is a meta node.

◆ isSubGraph()

virtual bool tlp::Graph::isSubGraph ( const Graph subGraph) const
pure virtual

Indicates if the graph argument is a direct subgraph.

Parameters
subGraphThe graph to check is a subgraph of this graph.
Returns
Whether subGraph is a direct subgraph of this graph.
See also
isDescendantGraph() to search in the whole hierarchy.

◆ nodePos()

virtual unsigned int tlp::Graph::nodePos ( const node  n) const
pure virtual

Return the position of a node in the vector of nodes of the graph.

Parameters
nThe node for which the position is requested

◆ nodes()

virtual const std::vector<node>& tlp::Graph::nodes ( ) const
pure virtual

Return a const reference on the vector of nodes of the graph It is the fastest way to access to nodes, Iterators are 25% slower.

Remarks
o(1)
+ Here is the caller graph for this function:

◆ numberOfDescendantGraphs()

virtual unsigned int tlp::Graph::numberOfDescendantGraphs ( ) const
pure virtual

Return the number of descendant subgraphs. For instance, in the following graph hierarchy: root / \ A B /|\ C D E.

@codeline root->numberOfSubGraphs(); Will return 5.

Returns
The number of descendants subgraphs.
See also
numberOfSubGraphs() to count only direct subgraphs.

◆ numberOfEdges()

virtual unsigned int tlp::Graph::numberOfEdges ( ) const
pure virtual

Gets the number of edges in this graph.

Returns
The number of edges in this graph.
See also
numberOfNodes()
+ Here is the caller graph for this function:

◆ numberOfNodes()

virtual unsigned int tlp::Graph::numberOfNodes ( ) const
pure virtual

Gets the number of nodes in this graph.

Returns
The number of nodes in this graph.
See also
numberOfEdges()
+ Here is the caller graph for this function:

◆ numberOfSubGraphs()

virtual unsigned int tlp::Graph::numberOfSubGraphs ( ) const
pure virtual

Return the number of direct subgraphs. For instance, in the following graph hierarchy: root / \ A B /|\ C D E.

@codeline root->numberOfSubGraphs(); Will return 2.

Returns
The number of direct subgraphs.
See also
numberOfDescendantGraphs() to count in the whole hierarchy.

◆ openMetaNode()

void tlp::Graph::openMetaNode ( node  n,
bool  updateProperties = true 
)

Opens a metanode and replaces all edges between that meta node and other nodes in the graph.

Warning
this method will fail when called on the root graph.
Parameters
nThe meta node to open.
updatePropertiesIf set to true, open meta node will update inner nodes layout, color, size, etc

◆ opposite()

virtual node tlp::Graph::opposite ( const edge  e,
const node  n 
) const
pure virtual

Gets the opposite node of n through e.

Parameters
eThe edge linking the two nodes.
nThe node at one end of e.
Returns
The node at the other end of e.

◆ outdeg()

virtual unsigned int tlp::Graph::outdeg ( const node  n) const
pure virtual

Get the output degree of a node.

Parameters
nThe node to get the output degree of.
Returns
The output degree of the given node.

◆ pop()

virtual void tlp::Graph::pop ( bool  unpopAllowed = true)
pure virtual

Undoes modifications and reverts the whole graph hierarchy back to a previous state.

Parameters
unpopAllowedWhether or not it is possible to redo what will be undoe by this call.

◆ popIfNoUpdates()

virtual void tlp::Graph::popIfNoUpdates ( )
pure virtual

abort last push if no updates have been recorded

◆ push()

virtual void tlp::Graph::push ( bool  unpopAllowed = true,
std::vector< PropertyInterface * > *  propertiesToPreserveOnPop = nullptr 
)
pure virtual

Saves the current state of the whole graph hierarchy and allows to revert to this state later on, using pop(). All modifications except those altering the ordering of the edges will be undone.

This allows to undo/redo modifications on a graph. This is mostly useful from a user interface point of view, but some algorithms use this mechanism to clean up before finishing. For instance:

Graph* graph = tlp::newGraph();
DoubleProperty* prop = graph->getProperty<DoubleProperty>("metric");
string errorMessage;
//our super metric stuff we want to kee
DoubleProperty* superProperty = graph->getProperty<DoubleProperty>("superStuff");
vector<PropertyInterface*> propertiesToKeep;
propertiesToKeep.push_back(superProperty);
//apply some metric
graph->applyPropertyAlgorithm("Degree", prop, errorMessage);
// save this state to be able to revert to it later
//however we do not want to allow to unpop(), which would go forward again to the state where
prop contains 'Depth'.
//this saves some memory.
//Also we always want to keep the value of our super property, so we pass it in the collection
of properties to leave unaffected by the pop().
graph->push(false, propertiesToKeep);
//compute the quality of this metric, or whatever makes sense
int degreeQuality = prop->getMax();
//compute another metric
graph->applyPropertyAlgorithm("Depth", prop, errorMessage);
//compute our secret metric, that depends on depth
graph->applyPropertyAlgorithm("MySuperSecretAlgorithm", superProperty, errorMessage);
//compute its quality
int depthQuality = prop->getMax();
//if the degree was better, revert back to the state where its contents were in prop.
if(degreeQuality > depthQuality) {
//this does not affect superProperty, as we told the system not to consider it when
recording modifications to potentially revert.
graph->pop();
}
//do some stuff using our high quality metric
ColorProperty* color = graph->getProperty("viewColor");
graph->applyPropertyAlgorithm("Color Mapping", color, errorMessage);
virtual void pop(bool unpopAllowed=true)=0
Undoes modifications and reverts the whole graph hierarchy back to a previous state.
Graph * newGraph()
Creates a new, empty graph.
Parameters
unpopAllowedWhether or not to allow to re-do the modifications once they are undone.
propertiesToPreserveOnPopA collection of properties whose state to preserve when using pop().
See also
pop()
popIfNoUpdates()
unpop()
canPop()
canUnPop()
canPopThenUnPop()

◆ removeAttribute()

void tlp::Graph::removeAttribute ( const std::string &  name)
inline

Removes an attribute on the graph.

Parameters
nameThe name of the attribute to remove.

Definition at line 1264 of file Graph.h.

◆ reverse()

virtual void tlp::Graph::reverse ( const edge  e)
pure virtual

Reverses the direction of an edge, the source becomes the target and the target becomes the source.

Warning
The ordering is global to the entire graph hierarchy. Thus, by changing the ordering of a graph you change the ordering of the hierarchy.
Parameters
eThe edge top reverse.

◆ setAttribute() [1/2]

template<typename ATTRIBUTETYPE >
void tlp::Graph::setAttribute ( const std::string &  name,
const ATTRIBUTETYPE &  value 
)

Sets an attribute on the graph.

Parameters
nameThe name of the attribute to set.
valueThe value to set on this attribute.

Definition at line 29 of file Graph.cxx.

+ Here is the call graph for this function:

◆ setAttribute() [2/2]

void tlp::Graph::setAttribute ( const std::string &  name,
const DataType value 
)

Sets an attribute on the graph.

Parameters
nameThe name of the attribute to set.
valueThe value to set.

◆ setEdgeOrder()

virtual void tlp::Graph::setEdgeOrder ( const node  n,
const std::vector< edge > &  edges 
)
pure virtual

Sets the order of the edges around a node. This operation ensures that adjacent edges of a node will be ordered as they are in the vector of edges given in parameter.

This can be useful if you want to make sure you retrieve the edges in a specific order when iterating upon them.

Parameters
nThe node whose edges to order.
edgesThe edges, in the order you want them.

◆ setEnds()

virtual void tlp::Graph::setEnds ( const edge  e,
const node  source,
const node  target 
)
pure virtual

Sets both the source and the target of an edge.

Parameters
eThe edge to set the source and target of.
sourceThe new source of the edge.
targetThe new target of the edge.

◆ setName()

virtual void tlp::Graph::setName ( const std::string &  name)
pure virtual

Sets the name of the graph. The name does not have to be unique, it is used for convenience.

Parameters
nameThe new name of the graph.

◆ setSource()

virtual void tlp::Graph::setSource ( const edge  e,
const node  source 
)
pure virtual

Sets the source of an edge to be the given node.

Parameters
eThe edge to change the source of.
sourceThe new source of the edge.

◆ setTarget()

virtual void tlp::Graph::setTarget ( const edge  e,
const node  target 
)
pure virtual

Sets the target of an edge to be the given node.

Parameters
eThe edge to change the target of.
targetThe new target of the edge.

◆ sortElts()

virtual void tlp::Graph::sortElts ( )
pure virtual

sort the graph elements in ascending order

Warning
: That operation modify the vector of nodes and the vector of edges and thus devalidate all iterators.

◆ source()

virtual node tlp::Graph::source ( const edge  e) const
pure virtual

Gets the source of an edge.

Parameters
eThe edge to get the source of.
Returns
The source of the given edge.

◆ subGraphs()

virtual const std::vector<Graph *>& tlp::Graph::subGraphs ( ) const
pure virtual

Return a const reference on the vector of subgraphs of the graph It is the fastest way to access to subgraphs, Iterators are 25% slower.

Remarks
o(1)

◆ swapEdgeOrder()

virtual void tlp::Graph::swapEdgeOrder ( const node  n,
const edge  e1,
const edge  e2 
)
pure virtual

Swaps two edges in the adjacency list of a node.

Parameters
nThe node on whoch to swap the edges order.
e1The first edge, that will take the second edge's position.
e2The second edge, that will take the first edge's position.

◆ target()

virtual node tlp::Graph::target ( const edge  e) const
pure virtual

Gets the target of an edge.

Parameters
eThe edge to get the target of.
Returns
The target of the given edge.

◆ unpop()

virtual void tlp::Graph::unpop ( )
pure virtual

Re-perform actions that were undone using pop().

For instance:

DoubleProperty* prop = graph->getProperty<DoubleProperty>("metric");
string errorMessage;
//apply some metric
graph->applyPropertyAlgorithm("Degree", prop, errorMessage);
// save this state to be able to revert to it later
graph->push();
//compute the quality of this metric, or whatever makes sense
int degreeQuality = prop->getMax();
//compute another metric
graph->applyPropertyAlgorithm("Depth", prop, errorMessage);
//compute its quality
int depthQuality = prop->getMax();
//if the degree was better, revert back to the state where its contents were in prop.
if(degreeQuality > depthQuality) {
graph->pop();
}
...
//revert back to the depth for some reason.
graph->unpop();