Tulip  4.1.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
tlp::Graph Class Referenceabstract

#include <Graph.h>

Inherits tlp::Observable.

Public Member Functions

virtual GraphaddCloneSubGraph (std::string name="unnamed")
 
virtual edge addEdge (const node source, const node target)=0
 
virtual void addEdge (const edge e)=0
 
virtual void addEdges (const std::vector< std::pair< node, node > > &edges, std::vector< edge > &addedEdges)=0
 
virtual void addEdges (Iterator< edge > *edges)=0
 
void _DEPRECATED addGraphObserver (Observable *) const
 
virtual void addLocalProperty (const std::string &name, PropertyInterface *prop)=0
 
virtual node addNode ()=0
 
virtual void addNode (const node n)=0
 
virtual void addNodes (unsigned int nbNodes, std::vector< node > &addedNodes)=0
 
virtual void addNodes (Iterator< node > *nodes)=0
 
virtual GraphaddSubGraph (BooleanProperty *selection=NULL, unsigned int id=0)=0
 
GraphaddSubGraph (std::string name)
 
bool applyAlgorithm (const std::string &algorithm, std::string &errorMessage, DataSet *dataSet=NULL, PluginProgress *progress=NULL)
 
bool applyPropertyAlgorithm (const std::string &algorithm, PropertyInterface *result, std::string &errorMessage, PluginProgress *progress=NULL, DataSet *parameters=NULL)
 
bool attributeExist (const std::string &name)
 
virtual bool canPop ()=0
 
virtual bool canPopThenUnpop ()=0
 
virtual bool canUnpop ()=0
 
virtual void clear ()=0
 
template<typename PropertyType >
_DEPRECATED bool computeProperty (const std::string &algorithm, PropertyType *result, std::string &msg, PluginProgress *progress=NULL, DataSet *data=NULL)
 
node createMetaNode (const std::set< node > &nodeSet, bool multiEdges=true, bool delAllEdge=true)
 
node createMetaNode (Graph *subGraph, bool multiEdges=true, bool delAllEdge=true)
 
void createMetaNodes (Iterator< Graph * > *itS, Graph *quotientGraph, std::vector< node > &metaNodes)
 
virtual unsigned int deg (const node n) const =0
 
virtual void delAllSubGraphs (Graph *graph)=0
 
virtual void delEdge (const edge e, bool deleteInAllGraphs=false)=0
 
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
 
virtual void delNodes (Iterator< node > *it, bool deleteInAllGraphs=false)=0
 
virtual const std::pair< node,
node > & 
ends (const edge e) const =0
 
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
 
template<typename ATTRIBUTETYPE >
bool getAttribute (const std::string &name, ATTRIBUTETYPE &value) const
 
DataTypegetAttribute (const std::string &name) const
 
const DataSetgetAttributes () const
 
virtual GraphgetDescendantGraph (unsigned int id) const =0
 
virtual GraphgetDescendantGraph (const std::string &name) const =0
 
virtual Iterator< edge > * getEdgeMetaInfo (const edge metaEdge) const =0
 
virtual Iterator< edge > * getEdges () 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
 
virtual PropertyInterfacegetProperty (const std::string &name) const =0
 
template<typename PropertyType >
PropertyType * getProperty (const std::string &name)
 
PropertyInterfacegetProperty (const std::string &propertyName, const std::string &propertyType)
 
virtual GraphgetRoot () const =0
 
virtual tlp::node getSource () const
 
virtual GraphgetSubGraph (unsigned int id) const =0
 
virtual GraphgetSubGraph (const std::string &name) const =0
 
virtual Iterator< Graph * > * getSubGraphs () const =0
 
virtual GraphgetSuperGraph () const =0
 
virtual unsigned int indeg (const node n) const =0
 
GraphinducedSubGraph (const std::set< node > &nodeSet, Graph *parentSubGraph=NULL)
 
virtual bool isDescendantGraph (const Graph *subGraph) const =0
 
virtual bool isElement (const node n) const =0
 
virtual bool isElement (const edge e) const =0
 
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 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 push (bool unpopAllowed=true, std::vector< PropertyInterface * > *propertiesToPreserveOnPop=NULL)=0
 
void removeAttribute (const std::string &name)
 
void _DEPRECATED removeGraphObserver (Observable *) const
 
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 node source (const edge e) 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 *const listener) 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 *const listener) const
 
void removeObserver (Observable *const observerver) const
 

Protected Member Functions

virtual bool canDeleteProperty (Graph *g, PropertyInterface *prop)
 
virtual void clearSubGraphs ()=0
 
virtual DataSetgetNonConstAttributes ()=0
 
void notifyAddEdge (const edge e)
 
void notifyAddEdge (Graph *, const edge e)
 
void notifyAddLocalProperty (const std::string &)
 
void notifyAddLocalProperty (Graph *, const std::string &name)
 
void notifyAddNode (const node n)
 
void notifyAddNode (Graph *, const node n)
 
void notifyAfterAddDescendantGraph (const Graph *)
 
void notifyAfterAddSubGraph (const Graph *)
 
void notifyAfterAddSubGraph (Graph *, const Graph *sg)
 
void notifyAfterDelDescendantGraph (const Graph *)
 
void notifyAfterDelLocalProperty (const std::string &)
 
void notifyAfterDelSubGraph (const Graph *)
 
void notifyAfterDelSubGraph (Graph *, const Graph *sg)
 
void notifyAfterSetAttribute (const std::string &)
 
void notifyAfterSetAttribute (Graph *, const std::string &name)
 
void notifyAfterSetEnds (const edge e)
 
void notifyAfterSetEnds (Graph *, const edge e)
 
void notifyBeforeAddDescendantGraph (const Graph *)
 
void notifyBeforeAddLocalProperty (const std::string &)
 
void notifyBeforeAddSubGraph (const Graph *)
 
void notifyBeforeAddSubGraph (Graph *, const Graph *sg)
 
void notifyBeforeDelDescendantGraph (const Graph *)
 
void notifyBeforeDelLocalProperty (const std::string &)
 
void notifyBeforeDelSubGraph (const Graph *)
 
void notifyBeforeDelSubGraph (Graph *, const Graph *sg)
 
void notifyBeforeSetAttribute (const std::string &)
 
void notifyBeforeSetAttribute (Graph *, const std::string &name)
 
void notifyBeforeSetEnds (const edge e)
 
void notifyBeforeSetEnds (Graph *, const edge e)
 
void notifyDelEdge (const edge e)
 
void notifyDelEdge (Graph *, const edge e)
 
void notifyDelLocalProperty (Graph *, const std::string &name)
 
void notifyDelNode (const node n)
 
void notifyDelNode (Graph *, const node n)
 
void notifyDestroy ()
 
void notifyDestroy (Graph *)
 
void notifyRemoveAttribute (const std::string &)
 
void notifyRemoveAttribute (Graph *, const std::string &name)
 
void notifyReverseEdge (const edge e)
 
void notifyReverseEdge (Graph *, const edge e)
 
virtual void removeEdge (const edge)=0
 
virtual void removeNode (const node)=0
 
virtual void removeSubGraph (Graph *)=0
 
virtual edge restoreEdge (edge, node source, node target)=0
 
virtual void restoreEdges (const std::vector< edge > &edges, const std::vector< std::pair< node, node > > &ends)=0
 
virtual node restoreNode (node)=0
 
virtual void restoreNodes (const std::vector< node > &nodes)=0
 
virtual void restoreSubGraph (Graph *)=0
 
virtual void setSubGraphToKeep (Graph *)=0
 
- Protected Member Functions inherited from tlp::Observable
 Observable (const Observable &)
 
tlp::Iterator< tlp::Observable * > * getObservables () const
 
bool hasOnlookers () const
 
void notifyObservers ()
 
void observableDeleted ()
 
Observableoperator= (const Observable &)
 
void sendEvent (const Event &message)
 
virtual void treatEvent (const Event &message)
 
virtual void treatEvents (const std::vector< Event > &events)
 

Protected Attributes

TLP_HASH_MAP< std::string,
tlp::PropertyInterface * > 
circularCalls
 
unsigned int id
 

Friends

class GraphAbstract
 
class GraphDecorator
 
class GraphUpdatesRecorder
 
class PropertyManager
 

Additional Inherited Members

- Static Public Member Functions inherited from tlp::Observable
static ObservablegetObject (tlp::node n)
 
static const tlp::VectorGraph & getObservableGraph ()
 
static void holdObservers ()
 
static bool isAlive (tlp::node n)
 
static unsigned int observersHoldCounter ()
 
static void unholdObservers ()
 

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.

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

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, ig 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).

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

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.

Examples:
graph_display/graph_display.cpp.

Definition at line 207 of file Graph.h.

Member Function Documentation

virtual Graph* tlp::Graph::addCloneSubGraph ( std::string  name = "unnamed")
virtual

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

Parameters
nameThe name of the newly created subgraph. Defaults to "unnamed".
Returns
:Graph* The newly created clone subgraph.
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.
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.
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 the addedEdges vector. The new edges are also added in all the 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.
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.
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.
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.
Examples:
clique_import/cliqueimport.cpp.
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.
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.
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.
virtual Graph* tlp::Graph::addSubGraph ( BooleanProperty selection = NULL,
unsigned int  id = 0 
)
pure virtual

Creates and returns a new sub-graph of this graph.

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

The id parameter should only be provided if you know exactly what you are doing; as Tulip will manage the subgraphs IDs when left to 0. It is only used by the Graph loading as subgraphs ids are preserved when saving/loading a Graph.

Parameters
selectionThe elements to add to the new subgraph. Defaults to 0.
idThe ID you wish to assign to the Graph. It is strongly advised to leave this as default and let Tulip manage subgraph IDs. Defaults to 0.
Returns
:Graph* The newly created subgraph.
Graph* tlp::Graph::addSubGraph ( std::string  name)

Creates and returns a new named sub-graph of this graph.

Parameters
nameThe name of the newly created subgraph. Defaults to "unnamed".
Returns
:Graph* The newly created subgraph.
bool tlp::Graph::applyAlgorithm ( const std::string &  algorithm,
std::string &  errorMessage,
DataSet dataSet = NULL,
PluginProgress progress = NULL 
)

Applies an algorithm plugin, identified by its name. Algorithm plugins are subclasses of the tlp::Algorithm interface. Parameters are transmitted to the algorithm trough 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 should an error occur.
dataSetThe parameters to the algorithm. Defaults to NULL.
progressA PluginProgress to report the progress of the operation, as well as final state. Defaults to NULL.
Returns
bool Whether the algorithm was successfully applied.
bool tlp::Graph::applyPropertyAlgorithm ( const std::string &  algorithm,
PropertyInterface result,
std::string &  errorMessage,
PluginProgress progress = NULL,
DataSet parameters = NULL 
)

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

Parameters
algorithmThe name of the plugin to run.
resultThe property in which to put the results. All previous values will be erased.
errorMessageStores the error message if the plugin fails.
progressA means of feedback during the plugin execution. Some plugins support being stopped or cancelled through this.
parametersThe parameters of the algorithm. Some algorithms use this DataSet to output some additional informations.
Returns
Whether the plugin executed successfully or not. If not, check the error message.
See Also
PluginLister::getPluginParameters() to retrieve the list of default parameters for the pligin.
bool tlp::Graph::attributeExist ( const std::string &  name)
inline

Checks if an attribute exists.

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

Definition at line 1011 of file Graph.h.

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.
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.
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().
virtual void tlp::Graph::clear ( )
pure virtual

Removes all nodes, edges and sub-graphs from this graph.

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

Returns
void
node tlp::Graph::createMetaNode ( const std::set< node > &  nodeSet,
bool  multiEdges = true,
bool  delAllEdge = true 
)

Creates a meta-node from a set of nodes. Every edges from any node in the set 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
nodeSetThe 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.
Returns
The newly created meta node.
node tlp::Graph::createMetaNode ( Graph subGraph,
bool  multiEdges = true,
bool  delAllEdge = true 
)

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
void tlp::Graph::createMetaNodes ( Iterator< Graph * > *  itS,
Graph quotientGraph,
std::vector< node > &  metaNodes 
)

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
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.
virtual void tlp::Graph::delAllSubGraphs ( Graph graph)
pure virtual

Deletes a sub-graph 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 sub-graph of this graph and all of its sub-graphs.
For instance, with a graph hierarchy as follows :
root
/ \
A B
/|\
C D E
@codeline root->delSubGraph(B);

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.
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 sub-graphs 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.
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 sub-graphs 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.
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.
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 sub-graphs 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.
virtual void tlp::Graph::delNodes ( Iterator< node > *  it,
bool  deleteInAllGraphs = false 
)
pure virtual

Deletes nodes in the graph. Thess nodes are also removed in the sub-graphs 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.
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.
virtual edge tlp::Graph::existEdge ( const node  source,
const node  target,
bool  directed = true 
) const
pure virtual

If an edge exists between the two given nodes, return it. If specified, include and edge that goes from target to source.

Returns the edge if it exists an edge between two nodes. The 'directed' flag indicates if the direction of the edge (from source to target) must be taken in to account. If no edge is found, returns an invalid edge.

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.
directedWhether to include edges going from target to source.
Returns
An edge that is only valid if it exists.
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.
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.
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 sucessful.

Definition at line 23 of file Graph.cxx.

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.
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 962 of file Graph.h.

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

Returns a pointer on the descendant with the corresponding id or NULL 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 NULL if no such graph exists in this graph's descendants.
See Also
getSubGraph(unsigned int) to search only in direct subgraphs.
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 NULL 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 NULL if there is no such graph in this graph's descendants.
See Also
getSubGraph(const std::string &) to search only in direct subgraphs.
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()
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()
unsigned int tlp::Graph::getId ( ) const
inline

Gets the unique identifier of the graph.

Returns
The unique identifier of this graph.

Definition at line 828 of file Graph.h.

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()
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.
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.
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, 0);

If you have 5 input nodes on a node N, then 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()
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()
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()
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.
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.
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.
template<typename PropertyType >
PropertyType * tlp::Graph::getLocalProperty ( const std::string &  name)

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

The graph keeps ownership of the property, if you wish to remove it fgrom 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 36 of file Graph.cxx.

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 NULL.
Parameters
propertyNameThe unique identifier of the property.
propertyTypeA string describing the type of the property.
Returns
The property of given name.
See Also
getLocalProperty().
virtual std::string tlp::Graph::getName ( ) const
pure virtual

Retrieves the name of the graph.

Returns
The name of the graph.
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()
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()
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 NULL;
Parameters
nthe index of the subgraph to retrieve.
Returns
The n-th subgraph.
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.
virtual edge tlp::Graph::getOneEdge ( ) const
pure virtual

Gets an edge of the graph.

Returns
Any one of the graph's edges.
virtual node tlp::Graph::getOneNode ( ) const
pure virtual

Gets a node on the graph.

Returns
Any node of the graph.
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()
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, 0);

If you have 5 output nodes on a node N, then 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()
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()
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.
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 NULL if no property with the given name exists.
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 NULL.
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.

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 NULL.
Parameters
propertyNameThe unique identifier of the property.
propertyTypeA string describing the type of the property.
Returns
The property of given name.
See Also
getProperty().
virtual Graph* tlp::Graph::getRoot ( ) const
pure virtual

Gets the root graph of the graph hierarchy.

Returns
The root graph of the graph hierarchy.
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.
virtual Graph* tlp::Graph::getSubGraph ( unsigned int  id) const
pure virtual

Returns a pointer on the sub-graph with the corresponding id or NULL if there is no sub-graph 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.
virtual Graph* tlp::Graph::getSubGraph ( const std::string &  name) const
pure virtual

Returns a pointer on the sub-graph with the corresponding name or NULL if there is no sub-graph with that name.

Parameters
nameThe name of the subgraph to retrieve.
Returns
A Graph named name, or NULL if no such subgraph exists on this graph.
See Also
getDescendantGraph(const std::string &) to search in the whole hierarchy.
virtual Iterator<Graph *>* tlp::Graph::getSubGraphs ( ) const
pure virtual

Gets an iterator on all the sub-graphs of the graph. For instance, in the followong graph hierarchy: root / \ A B /|\ C D E.

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.
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.
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.
Graph* tlp::Graph::inducedSubGraph ( const std::set< node > &  nodeSet,
Graph parentSubGraph = NULL 
)

Creates and returns a new sub-graph of the graph induced by a set of nodes. Every node contained in the given set of nodes is added to the subgraph. Every edge connecting any two nodes in the set of given nodes is also added.

Parameters
nodeSetThe 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.
Returns
The newly created subgraph.
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.
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.
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.
virtual bool tlp::Graph::isMetaEdge ( const edge  e) const
pure virtual

Checks is 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.
virtual bool tlp::Graph::isMetaNode ( const node  n) const
pure virtual

Checks is 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.
virtual bool tlp::Graph::isSubGraph ( const Graph subGraph) const
pure virtual

Indicates if the graph argument is a direct sub-graph.

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.
virtual unsigned int tlp::Graph::numberOfDescendantGraphs ( ) const
pure virtual

Return the number of descendant sub-graphs. For instance, in the followong graph hierarchy: root / \ A B /|\ C D E.

root->numberOfSubGraphs(); Will return 5.

Returns
The number of descendants subgraphs.
See Also
numberOfSubGraphs() to count only direct subgraphs.
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()
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()
virtual unsigned int tlp::Graph::numberOfSubGraphs ( ) const
pure virtual

Return the number of direct sub-graphs. For instance, in the followong graph hierarchy: root / \ A B /|\ C D E.

root->numberOfSubGraphs(); Will return 2.

Returns
The number of direct subgraphs.
See Also
numberOfDescendantGraphs() to count in the whole hierarchy.
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
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.
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.
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.
virtual void tlp::Graph::push ( bool  unpopAllowed = true,
std::vector< PropertyInterface * > *  propertiesToPreserveOnPop = NULL 
)
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);
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()
unpop()
canPop()
canUnPop()
canPopThenUnPop()
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 1001 of file Graph.h.

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.
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 28 of file Graph.cxx.

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.
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.
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.
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.
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.
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.
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.
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.
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.
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();