Tulip
4.6.0
Better Visualization Through Research
|
#include <Graph.h>
Public Member Functions | |
virtual Graph * | addCloneSubGraph (const std::string &name="unnamed", bool addSibling=false) |
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 | addEdges (const std::vector< edge > &edges) |
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 |
void | addNodes (const std::vector< node > &nodes) |
virtual Graph * | addSubGraph (BooleanProperty *selection=NULL, const std::string &name="unnamed")=0 |
Graph * | addSubGraph (const 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 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 |
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 |
void | delEdges (const std::vector< edge > &edges, bool deleteInAllGraphs=false) |
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 |
void | delNodes (const std::vector< node > &nodes, bool deleteInAllGraphs=false) |
virtual Iterator< node > * | dfs (const node root=node()) const =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 |
DataType * | getAttribute (const std::string &name) const |
const DataSet & | getAttributes () const |
virtual Graph * | getDescendantGraph (unsigned int id) const =0 |
virtual Graph * | getDescendantGraph (const std::string &name) const =0 |
Iterator< Graph * > * | getDescendantGraphs () const |
virtual Iterator< edge > * | getEdgeMetaInfo (const edge metaEdge) const =0 |
virtual Iterator< edge > * | getEdges () const =0 |
virtual std::vector< edge > | getEdges (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) |
PropertyInterface * | getLocalProperty (const std::string &propertyName, const std::string &propertyType) |
virtual std::string | getName () const =0 |
virtual Graph * | getNodeMetaInfo (const node metaNode) const =0 |
virtual Iterator< node > * | getNodes () const =0 |
virtual Graph * | getNthSubGraph (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 PropertyInterface * | getProperty (const std::string &name) const =0 |
template<typename PropertyType > | |
PropertyType * | getProperty (const std::string &name) |
PropertyInterface * | getProperty (const std::string &propertyName, const std::string &propertyType) |
virtual Graph * | getRoot () const =0 |
virtual tlp::node | getSource () const |
virtual Graph * | getSubGraph (unsigned int id) const =0 |
virtual Graph * | getSubGraph (const std::string &name) const =0 |
virtual Iterator< Graph * > * | getSubGraphs () const =0 |
virtual Graph * | getSuperGraph () const =0 |
virtual bool | hasEdge (const node source, const node target, bool directed=true) const |
virtual unsigned int | indeg (const node n) const =0 |
Graph * | inducedSubGraph (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) |
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 |
Protected Member Functions | |
virtual bool | canDeleteProperty (Graph *g, PropertyInterface *prop) |
virtual void | clearSubGraphs ()=0 |
virtual DataSet & | getNonConstAttributes ()=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 bool | renameLocalProperty (PropertyInterface *prop, const std::string &newName)=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 Attributes | |
TLP_HASH_MAP< std::string, tlp::PropertyInterface * > | circularCalls |
unsigned int | id |
Friends | |
class | GraphAbstract |
class | GraphDecorator |
class | GraphUpdatesRecorder |
class | PropertyInterface |
class | PropertyManager |
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.
virtual Graph* tlp::Graph::addCloneSubGraph | ( | const std::string & | name = "unnamed" , |
bool | addSibling = false |
||
) | [virtual] |
Creates and returns a subgraph that contains all the elements of this graph.
name | The name of the newly created subgraph. Defaults to "unnamed". |
addSibling | if true the clone subgraph will be a sibling of this graph, if false (the default) it will be a subgraph of this graph |
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.
source | The source of the edge. |
target | The target of the edge. |
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.
e | The edge to add to this subgraph. |
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.
edges | A vector describing between which nodes to add edges. The first element of the pair is the source, the second is the destination. |
addedEdges | The 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.
edges | The edges to add on this subgraph. |
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.
edges | a vector of the 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().
name | The unique identifier of the property. |
prop | The 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.
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).
n | The node to add to a subgraph. This node must exist in the root graph. |
virtual void tlp::Graph::addNodes | ( | unsigned int | nbNodes, |
std::vector< node > & | addedNodes | ||
) | [pure virtual] |
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.
nodes | An iterator over nodes to add to this subgraph. The graph does not takes ownership of this iterator. |
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.
nodes | a vector of nodes to add to this subgraph. |
virtual Graph* tlp::Graph::addSubGraph | ( | BooleanProperty * | selection = NULL , |
const std::string & | name = "unnamed" |
||
) | [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.
selection | The elements to add to the new subgraph. Defaults to 0. |
name | The name of the newly created subgraph. Defaults to "unnamed". |
Graph* tlp::Graph::addSubGraph | ( | const std::string & | name | ) |
Creates and returns a new named sub-graph of this graph.
name | The name of 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.
algorithm | The algorithm to apply. |
errorMessage | A string that will be modified to contain an error message should an error occur. |
dataSet | The parameters to the algorithm. Defaults to NULL. |
progress | A PluginProgress to report the progress of the operation, as well as final state. Defaults to NULL. |
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.
algorithm | The name of the plugin to run. |
result | The property in which to put the results. All previous values will be erased. |
errorMessage | Stores the error message if the plugin fails. |
progress | A means of feedback during the plugin execution. Some plugins support being stopped or cancelled through this. |
parameters | The parameters of the algorithm. Some algorithms use this DataSet to output some additional information. |
bool tlp::Graph::attributeExist | ( | const std::string & | name | ) | [inline] |
virtual Iterator<node>* tlp::Graph::bfs | ( | const node | root = node() | ) | const [pure virtual] |
Gets an iterator performing a breadth-first search on the graph.
root | The 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. |
virtual bool tlp::Graph::canPop | ( | ) | [pure virtual] |
virtual bool tlp::Graph::canPopThenUnpop | ( | ) | [pure virtual] |
Checks if it is possible to call pop() and then unPop(), to undo then re-do modifications.
virtual bool tlp::Graph::canUnpop | ( | ) | [pure virtual] |
Checks if the last undone modifications can be redone.
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.
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.
nodeSet | The nodes to put into the meta node. |
multiEdges | Whether a meta edge should be created for each underlying edge. |
delAllEdge | Whether the underlying edges will be removed from the whole hierarchy. |
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.
subGraph | an existing subgraph |
multiEdges | indicates if a meta edge will be created for each underlying edge |
delAllEdge | indicates 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.
itS | a Graph iterator, (typically a subgraph iterator) |
quotientGraph | the graph that will contain the meta nodes |
metaNodes | will contains all the added meta nodes after the call |
virtual unsigned int tlp::Graph::deg | ( | const node | n | ) | const [pure virtual] |
n | The node to get the degree of. |
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
graph | The subgraph to delete. |
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.
e | The edge to delete. |
deleteInAllGraphs | Whether 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.
itE | |
deleteInAllGraphs | Whether to delete in all its parent graphs or only in this graph. By default only removes in the current graph. |
void tlp::Graph::delEdges | ( | const std::vector< edge > & | edges, |
bool | deleteInAllGraphs = false |
||
) |
Deletes edges in the graph. These edges are also removed in the sub-graphs hierarchy. The ordering of remaining edges is preserved.
edges | a vector of the edges to delete |
deleteInAllGraphs | Whether 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.
name | The 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.
n | The node to delete. |
deleteInAllGraphs | Whether to delete in all its parent graphs or only in this graph. By default only removes in the current graph. |
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 sub-graphs hierarchy of the current graph.
it | The nodes to delete. |
deleteInAllGraphs | Whether to delete in all its parent graphs or only in this graph. By default only removes in the current graph. |
void tlp::Graph::delNodes | ( | const std::vector< node > & | nodes, |
bool | deleteInAllGraphs = false |
||
) |
Deletes nodes in the graph. These nodes are also removed in the sub-graphs hierarchy of the current graph.
nodes | a vector of the nodes to delete. |
deleteInAllGraphs | Whether to delete in all its parent graphs or only in this graph. By default only removes in the current graph. |
virtual Iterator<node>* tlp::Graph::dfs | ( | const node | root = node() | ) | const [pure virtual] |
Gets an iterator performing a depth-first search on the graph.
root | The 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. |
virtual const std::pair<node, node>& tlp::Graph::ends | ( | const edge | e | ) | const [pure virtual] |
Gets the source and the target of an edge.
e | The edge to get the ends of. |
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.
source | The source of the hypothetical edge. |
target | The target of the hypothetical edge. |
directed | When set to false an edge from target to source may also be returned |
virtual bool tlp::Graph::existLocalProperty | ( | const std::string & | name | ) | const [pure virtual] |
Checks if a property exists in this graph.
The | unique identifier of the property. |
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.
The | unique identifier of the property. |
bool tlp::Graph::getAttribute | ( | const std::string & | name, |
ATTRIBUTETYPE & | value | ||
) | const |
DataType* tlp::Graph::getAttribute | ( | const std::string & | name | ) | const |
Gets a copy of the attribute.
name | The name of the attribute to retrieve. |
const DataSet& tlp::Graph::getAttributes | ( | ) | const [inline] |
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.
id | The id of the descendant graph to retrieve. |
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.
name | The name of the descendant graph to look for. |
Iterator<Graph *>* tlp::Graph::getDescendantGraphs | ( | ) | const |
Gets an iterator over all the descendant sub-graphs of the graph. For instance, in the following graph hierarchy: root / \ A B /|\ C D E.
root->getSubGraphs(); Will return an iterator over A B, C, D and E.
virtual Iterator<edge>* tlp::Graph::getEdgeMetaInfo | ( | const edge | metaEdge | ) | const [pure virtual] |
Gets an iterator over the edges composing a meta edge.
metaEdge | The metaEdge to get the real edges of. |
virtual Iterator<edge>* tlp::Graph::getEdges | ( | ) | const [pure virtual] |
Get an iterator over all the graph's edges.
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.
source | The source of the hypothetical edges. |
target | The target of the hypothetical edges. |
directed | When set to false edges from target to source are also considered |
unsigned int tlp::Graph::getId | ( | ) | const [inline] |
virtual Iterator<edge>* tlp::Graph::getInEdges | ( | const node | n | ) | const [pure virtual] |
Gets an iterator over the input edges of a node.
n | The node to get the input edges from. |
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.
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.
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 graph->getInNode(2); will return the second of those nodes. It will ignore the output nodes of this node.
n | The node to get an input node of. |
i | The index of the input node to get. |
virtual Iterator<node>* tlp::Graph::getInNodes | ( | const node | n | ) | const [pure virtual] |
Gets an iterator over the input nodes of a node.
n | The node to get the input nodes of. |
virtual Iterator<edge>* tlp::Graph::getInOutEdges | ( | const node | n | ) | const [pure virtual] |
Gets an iterator over the edges of a node.
n | The node to get the edges from. |
virtual Iterator<node>* tlp::Graph::getInOutNodes | ( | const node | n | ) | const [pure virtual] |
Gets an iterator over the neighbors of a given node.
n | The node to retrieve the neighbors of. |
virtual Iterator<PropertyInterface*>* tlp::Graph::getLocalObjectProperties | ( | ) | const [pure virtual] |
Gets an iterator over the local properties of this graph.
virtual Iterator<std::string>* tlp::Graph::getLocalProperties | ( | ) | const [pure virtual] |
Gets an iterator over the names of the local properties of this graph.
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().
The | unique identifier of the property. |
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().
propertyName | The unique identifier of the property. |
propertyType | A string describing the type of the property. |
virtual std::string tlp::Graph::getName | ( | ) | const [pure virtual] |
Retrieves the name of the graph.
virtual Graph* tlp::Graph::getNodeMetaInfo | ( | const node | metaNode | ) | const [pure virtual] |
Gets the underlying graph of a meta node.
metaNode | The metanode. |
virtual Iterator<node>* tlp::Graph::getNodes | ( | ) | const [pure virtual] |
Gets an iterator over this graph's nodes.
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;
n | the index of the subgraph to retrieve. |
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.
virtual edge tlp::Graph::getOneEdge | ( | ) | const [pure virtual] |
Gets an edge of the graph.
virtual node tlp::Graph::getOneNode | ( | ) | const [pure virtual] |
Gets a node on the graph.
virtual Iterator<edge>* tlp::Graph::getOutEdges | ( | const node | n | ) | const [pure virtual] |
Gets an iterator over the output edges of a node.
n | The node to get the output edges from. |
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 graph->getOutNode(2); will return the second of those nodes. It will ignore the input nodes of this node.
n | The node to get an output node of. |
i | The index of the output node to get. |
virtual Iterator<node>* tlp::Graph::getOutNodes | ( | const node | n | ) | const [pure virtual] |
Gets an iterator over the output nodes of a node.
n | The node to get the output nodes of. |
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.
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().
name | The unique identifier of the property. |
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().
name | The unique identifier of the property. |
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().
propertyName | The unique identifier of the property. |
propertyType | A string describing the type of the property. |
virtual Graph* tlp::Graph::getRoot | ( | ) | const [pure virtual] |
Gets the root graph of the graph hierarchy.
virtual tlp::node tlp::Graph::getSource | ( | ) | const [virtual] |
Finds the first node whose input degree equals 0.
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.
id | The id of the subgraph to retrieve. |
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.
name | The name of the subgraph to retrieve. |
virtual Iterator<Graph *>* tlp::Graph::getSubGraphs | ( | ) | const [pure virtual] |
Gets an iterator over all the sub-graphs of the graph. For instance, in the following graph hierarchy: root / \ A B /|\ C D E.
root->getSubGraphs(); Will return an iterator over A and B, but not C, D and E.
virtual Graph* tlp::Graph::getSuperGraph | ( | ) | const [pure virtual] |
Returns the parent of the graph. If called on the root graph, it returns itself.
virtual bool tlp::Graph::hasEdge | ( | const node | source, |
const node | target, | ||
bool | directed = true |
||
) | const [inline, virtual] |
Checks if an edge exists between two given nodes.
source | The source of the hypothetical edge. |
target | The target of the hypothetical edge. |
directed | When set to false edges from target to source are also considered |
Definition at line 992 of file Graph.h.
virtual unsigned int tlp::Graph::indeg | ( | const node | n | ) | const [pure virtual] |
Get the input degree of a node.
n | The node to get the input degree of. |
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.
nodeSet | The nodes to add to the subgraph. All the edges between these nodes are added too. |
parentSubGraph | If provided, is used as parent graph for the newly created subgraph instead of the graph this method is called on. |
virtual bool tlp::Graph::isDescendantGraph | ( | const Graph * | subGraph | ) | const [pure virtual] |
Indicates if the graph argument is a descendant of this graph.
subGraph | The graph to check is a descendant of this graph. |
virtual bool tlp::Graph::isElement | ( | const node | n | ) | const [pure virtual] |
Checks if an element belongs to this graph.
n | The node to check if it is an element of the graph. |
virtual bool tlp::Graph::isElement | ( | const edge | e | ) | const [pure virtual] |
Checks if an element belongs to this graph.
e | The edge to check if it is an element of the graph. |
virtual bool tlp::Graph::isMetaEdge | ( | const edge | e | ) | const [pure virtual] |
Checks if an edge is a meta edge.
e | The edge to check if it is a meta edge. |
virtual bool tlp::Graph::isMetaNode | ( | const node | n | ) | const [pure virtual] |
Checks if a node is a meta node.
n | The node to check if it 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.
subGraph | The graph to check is a subgraph of this graph. |
virtual unsigned int tlp::Graph::numberOfDescendantGraphs | ( | ) | const [pure virtual] |
Return the number of descendant sub-graphs. For instance, in the following graph hierarchy: root / \ A B /|\ C D E.
root->numberOfSubGraphs(); Will return 5.
virtual unsigned int tlp::Graph::numberOfEdges | ( | ) | const [pure virtual] |
Gets the number of edges in this graph.
virtual unsigned int tlp::Graph::numberOfNodes | ( | ) | const [pure virtual] |
Gets the number of nodes in this graph.
virtual unsigned int tlp::Graph::numberOfSubGraphs | ( | ) | const [pure virtual] |
Return the number of direct sub-graphs. For instance, in the following graph hierarchy: root / \ A B /|\ C D E.
root->numberOfSubGraphs(); Will return 2.
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.
n | The meta node to open. |
updateProperties | If 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.
e | The edge linking the two nodes. |
n | The node at one end of e. |
virtual unsigned int tlp::Graph::outdeg | ( | const node | n | ) | const [pure virtual] |
Get the output degree of a node.
n | The node to get the output degree of. |
virtual void tlp::Graph::pop | ( | bool | unpopAllowed = true | ) | [pure virtual] |
Undoes modifications and reverts the whole graph hierarchy back to a previous state.
unpopAllowed | Whether 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);
unpopAllowed | Whether or not to allow to re-do the modifications once they are undone. |
propertiesToPreserveOnPop | A collection of properties whose state to preserve when using pop(). |
void tlp::Graph::removeAttribute | ( | const std::string & | name | ) | [inline] |
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.
e | The edge top reverse. |
void tlp::Graph::setAttribute | ( | const std::string & | name, |
const ATTRIBUTETYPE & | value | ||
) |
void tlp::Graph::setAttribute | ( | const std::string & | name, |
const DataType * | value | ||
) |
Sets an attribute on the graph.
name | The name of the attribute to set. |
value | The 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.
n | The node whose edges to order. |
edges | The 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.
e | The edge to set the source and target of. |
source | The new source of the edge. |
target | The 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.
name | The 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.
e | The edge to change the source of. |
source | The 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.
e | The edge to change the target of. |
target | The new target of the edge. |
virtual node tlp::Graph::source | ( | const edge | e | ) | const [pure virtual] |
Gets the source of an edge.
e | The edge to get the source of. |
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.
n | The node on whoch to swap the edges order. |
e1 | The first edge, that will take the second edge's position. |
e2 | The 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.
e | The edge to get the target of. |
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();