Tulip
5.2.1
Large graphs analysis and drawing
|
#include <Graph.h>
Public Member Functions | |
virtual Graph * | addCloneSubGraph (const std::string &name="unnamed", bool addSibling=false, bool addSiblingProperties=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)=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)=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=nullptr, const std::string &name="unnamed")=0 |
Graph * | addSubGraph (const std::string &name) |
virtual const std::vector< edge > & | allEdges (const node n) const =0 |
bool | applyAlgorithm (const std::string &algorithm, std::string &errorMessage, DataSet *parameters=nullptr, PluginProgress *progress=nullptr) |
bool | applyPropertyAlgorithm (const std::string &algorithm, PropertyInterface *result, std::string &errorMessage, DataSet *parameters=nullptr, PluginProgress *progress=nullptr) |
bool | applyPropertyAlgorithm (const std::string &algorithm, PropertyInterface *result, std::string &errorMessage, PluginProgress *progress, DataSet *parameters=nullptr) |
bool | attributeExist (const std::string &name) const |
virtual Iterator< node > * | bfs (const node root=node()) const =0 |
virtual bool | canPop ()=0 |
virtual bool | canPopThenUnpop ()=0 |
virtual bool | canUnpop ()=0 |
virtual void | clear ()=0 |
virtual node | createMetaNode (const std::vector< node > &nodes, bool multiEdges=true, bool delAllEdge=true) |
node | createMetaNode (const std::set< node > &nodeSet, bool multiEdges=true, bool delAllEdge=true) |
virtual node | createMetaNode (Graph *subGraph, bool multiEdges=true, bool delAllEdge=true) |
virtual 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=nullptr)=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 unsigned int | edgePos (const edge e) const =0 |
virtual const std::vector< edge > & | edges () const =0 |
virtual const std::pair< node, node > & | ends (const edge e) const =0 |
bool | existAttribute (const std::string &name) const |
virtual edge | existEdge (const node source, const node target, bool directed=true) const =0 |
virtual bool | existLocalProperty (const std::string &name) const =0 |
virtual bool | existProperty (const std::string &name) const =0 |
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 edge | getRandomEdge () const =0 |
virtual node | getRandomNode () const =0 |
virtual Graph * | getRoot () const =0 |
virtual tlp::node | getSink () const |
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::vector< node > &nodes, Graph *parentSubGraph=nullptr, const std::string &name="unnamed") |
Graph * | inducedSubGraph (const std::set< node > &nodeSet, Graph *parentSubGraph=nullptr, const std::string &name="unnamed") |
Graph * | inducedSubGraph (BooleanProperty *selection, Graph *parentSubGraph=nullptr, const std::string &name="unnamed") |
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 | isEmpty () const |
virtual bool | isMetaEdge (const edge e) const =0 |
virtual bool | isMetaNode (const node n) const =0 |
virtual bool | isSubGraph (const Graph *subGraph) const =0 |
virtual unsigned int | nodePos (const node n) const =0 |
virtual const std::vector< node > & | nodes () const =0 |
virtual unsigned int | numberOfDescendantGraphs () const =0 |
virtual unsigned int | numberOfEdges () const =0 |
virtual unsigned int | numberOfNodes () const =0 |
virtual unsigned int | numberOfSubGraphs () const =0 |
void | openMetaNode (node n, bool updateProperties=true) |
virtual node | opposite (const edge e, const node n) const =0 |
virtual unsigned int | outdeg (const node n) const =0 |
virtual void | pop (bool unpopAllowed=true)=0 |
virtual void | popIfNoUpdates ()=0 |
virtual void | push (bool unpopAllowed=true, std::vector< PropertyInterface *> *propertiesToPreserveOnPop=nullptr)=0 |
void | removeAttribute (const std::string &name) |
virtual void | reserveEdges (unsigned int nbEdges)=0 |
virtual void | reserveNodes (unsigned int nbNodes)=0 |
virtual void | reverse (const edge e)=0 |
template<typename ATTRIBUTETYPE > | |
void | setAttribute (const std::string &name, const ATTRIBUTETYPE &value) |
void | setAttribute (const std::string &name, const DataType *value) |
virtual void | setEdgeOrder (const node n, const std::vector< edge > &edges)=0 |
virtual void | setEnds (const edge e, const node source, const node target)=0 |
virtual void | setName (const std::string &name)=0 |
virtual void | setSource (const edge e, const node source)=0 |
virtual void | setSuperGraph (Graph *)=0 |
virtual void | setTarget (const edge e, const node target)=0 |
virtual void | sortElts ()=0 |
virtual node | source (const edge e) const =0 |
virtual const std::vector< Graph * > & | subGraphs () const =0 |
virtual void | swapEdgeOrder (const node n, const edge e1, const edge e2)=0 |
virtual node | target (const edge e) const =0 |
virtual void | unpop ()=0 |
Public Member Functions inherited from tlp::Observable | |
void | addListener (Observable *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 |
Friends | |
class | GraphAbstract |
class | GraphDecorator |
class | GraphUpdatesRecorder |
class | PropertyInterface |
class | PropertyManager |
Additional Inherited Members | |
Static Public Member Functions inherited from tlp::Observable | |
static void | disableEventNotification () |
static void | enableEventNotification () |
static tlp::node | getNode (const tlp::Observable *obs) |
static Observable * | getObject (tlp::node n) |
static const tlp::VectorGraph & | getObservableGraph () |
static unsigned int | getScheduled (tlp::node n) |
static void | holdObservers () |
static bool | isAlive (tlp::node n) |
static unsigned int | observersHoldCounter () |
static void | unholdObservers () |
Protected Member Functions inherited from tlp::Observable | |
Observable (const Observable &) | |
bool | hasOnlookers () const |
void | observableDeleted () |
Observable & | operator= (const Observable &) |
void | sendEvent (const Event &message) |
virtual void | treatEvent (const Event &message) |
virtual void | treatEvents (const std::vector< Event > &events) |
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, if you have the following graph hierarchy: root / \ A B
Every node in A is in root, and every node in B is in root. Nodes can be in A and root but not B; or in B and root but not A.
For instance, imagine a graph. You want to compare it to its Delaunay triangulation. You need to create a subgraph that is a clone of the original (say this is A) to keep the original graph, and another copy (say this one is B) on which you will perform the delaunay triangulation.
B will have none of the original edges, and A will have only the original edges.
As for properties; let's imagine the same graph hierarchy. You want to compare two different layouts on the same graph. You need to create two clone subgraphs, on each you make the 'viewLayout' property local. This results in A and B having different values for the layout, but everything else in common. You then can apply two different algorithms on A and B (e.g. Bubble Tree and Tree Radial).
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 |
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 |
addSiblingProperties | if true the local properties will be cloned into the sibling of this graph, if false (the default) the local properties will not be cloned |
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. |
|
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. |
|
pure virtual |
Adds new edges in the graph. The new edges are also added in all 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. |
|
pure virtual |
Adds new edges in the graph and returns them in the addedEdges vector. The new edges are also added in all graph ancestors.
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. |
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. |
|
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. |
|
pure virtual |
Adds a new node in the graph and returns it. This node is also added in all the ancestor graphs.
|
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. |
|
pure virtual |
|
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. |
|
pure virtual |
Creates and returns a new subgraph of this graph.
If a BooleanProperty is provided, only nodes and edges for which it is true will be added to the subgraph. If none is provided, then the subgraph will be empty.
selection | The elements to add to the new subgraph. Defaults to nullptr. |
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 subgraph of this graph.
name | The name of the newly created subgraph. |
Gets all input/output edges of a node existing in the root graph.
n | The node to get the input/ouput edges from. |
bool tlp::Graph::applyAlgorithm | ( | const std::string & | algorithm, |
std::string & | errorMessage, | ||
DataSet * | parameters = nullptr , |
||
PluginProgress * | progress = nullptr |
||
) |
Applies an algorithm plugin, identified by its name. Algorithm plugins are subclasses of the tlp::Algorithm interface. Parameters are transmitted to the algorithm trough the DataSet. To determine a plugin's parameters, you can either:
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 if an error occurs. |
parameters | The parameters of the algorithm. Defaults to nullptr. |
progress | A PluginProgress to report the progress of the operation, as well as the final state. Defaults to nullptr. |
bool tlp::Graph::applyPropertyAlgorithm | ( | const std::string & | algorithm, |
PropertyInterface * | result, | ||
std::string & | errorMessage, | ||
DataSet * | parameters = nullptr , |
||
PluginProgress * | progress = nullptr |
||
) |
Runs a plugin on the graph, whose result is a property.
algorithm | The name of the plugin to run. |
result | The property in which to store the computed nodes/edges associated values. All previous values will be erased. |
errorMessage | Stores the error message if the plugin fails. |
parameters | The parameters of the algorithm. Some algorithms use this DataSet to output |
progress | A PluginProgress to report the progress of the operation, as well as the final state. Defaults to nullptr. some additional information. |
|
inline |
Deprecated, use applyPropertyAlgorithm(const std::string &algorithm, PropertyInterface *result, std::string &errorMessage, DataSet *parameters = nullptr, PluginProgress *progress = nullptr) instead.
|
inline |
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. |
|
pure virtual |
|
pure virtual |
Checks if it is possible to call pop() and then unPop(), to undo then re-do modifications.
|
pure virtual |
Checks if the last undone modifications can be redone.
|
pure virtual |
Removes all nodes, edges and subgraphs from this graph.
Contrarily to creating a new Graph, this keeps attributes and properties.
|
virtual |
Creates a meta-node from a vector of nodes. Every edges from any node in the vector to another node of the graph will be replaced with meta edges from the meta node to the other nodes.
nodes | The vector of 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 | ( | const std::set< node > & | nodeSet, |
bool | multiEdges = true , |
||
bool | delAllEdge = true |
||
) |
Deprecated, use createMetaNode(const std::vector<node>&, bool multiEdges = true, bool delAllEdge = true) instead.
|
virtual |
Closes an existing subgraph into a metanode. Edges from nodes in the subgraph to nodes outside the subgraph are replaced with edges from the metanode to the nodes outside the subgraph.
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 |
|
virtual |
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 |
|
pure virtual |
n | The node to get the degree of. |
|
pure virtual |
Deletes a subgraph of this graph. All subgraphs of the removed graph are re-parented to this graph. For instance, with a graph hierarchy as follows : root / \ A B /|\ C D E.
would result in the following hierarchy: root | A
graph | The subgraph to delete. |
|
pure virtual |
Deletes an edge in the graph. The edge is also removed in the subgraphs 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. |
|
pure virtual |
Deletes edges in the graph. These edges are also removed in the subgraphs 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 subgraphs 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. |
|
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. |
|
pure virtual |
Deletes a node in the graph. This node is also removed in the subgraphs 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. |
|
pure virtual |
Deletes nodes in the graph. These nodes are also removed in the subgraphs 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 subgraphs 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. |
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. |
|
pure virtual |
Return the position of an edge in the vector of edges of the graph.
e | The edge for which the position is requested |
|
pure virtual |
Return a const reference on the vector of edges of the graph It is the fastest way to access to edges, Iterators are 25% slower.
Gets the source and the target of an edge.
e | The edge to get the ends of. |
|
inline |
|
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 |
|
pure virtual |
Checks if a property exists in this graph.
The | unique identifier of the property. |
|
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. |
|
inline |
|
pure virtual |
Returns a pointer on the descendant with the corresponding id or nullptr if there is no descendant with that id.
id | The id of the descendant graph to retrieve. |
|
pure virtual |
Returns a pointer on the first descendant graph with the corresponding name or nullptr if there is no descendant graph with that name.
name | The name of the descendant graph to look for. |
Gets an iterator over all the descendant subgraphs 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.
Gets an iterator over the edges composing a meta edge.
metaEdge | The metaEdge to get the real edges of. |
Get an iterator over all the graph's edges.
|
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 |
|
inline |
Gets an iterator over the input edges of a node.
n | The node to get the input edges from. |
|
pure virtual |
Gets an iterator over the properties inherited from this graph's ancestors, excluding this graph's local properties.
|
pure virtual |
Gets an iterator over the names of the properties inherited from this graph's ancestors, excluding this graph's local properties.
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.
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. |
Gets an iterator over the input nodes of a node.
n | The node to get the input nodes of. |
Gets an iterator over the edges of a node.
n | The node to get the edges from. |
Gets an iterator over the neighbors of a given node.
n | The node to retrieve the neighbors of. |
|
pure virtual |
Gets an iterator over the local properties of this graph.
|
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 identifies it uniquely. Either there already exists a property with the given name, in which case it is returned. Either no such property exists and it is created.
The graph keeps ownership of the property, if you wish to remove it from the graph use Graph::delLocalProperty().
The | unique identifier of the property. |
Definition at line 37 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().
propertyName | The unique identifier of the property. |
propertyType | A string describing the type of the property. |
|
pure virtual |
Retrieves the name of the graph.
Gets the underlying graph of a meta node.
metaNode | The metanode. |
Gets an iterator over this graph's nodes.
|
virtual |
This method returns the nth subgraph. Since subgraphs order cannot be ensured in every implementation, this method should be equivalent to:
n | the index of the subgraph to retrieve. |
|
pure virtual |
Gets an iterator over the properties attached to this graph, whether they are local or inherited.
|
pure virtual |
Returns the first edge in the graph.
|
pure virtual |
Returns the first node in the graph.
Gets an iterator over the output edges of a node.
n | The node to get the output edges from. |
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.
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. |
Gets an iterator over the output nodes of a node.
n | The node to get the output nodes of. |
|
pure virtual |
Gets an iterator over the names of all the properties attached to this graph, whether they are local or inherited.
|
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. |
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().
propertyName | The unique identifier of the property. |
propertyType | A string describing the type of the property. |
|
pure virtual |
Returns a random edge in the graph.
|
pure virtual |
Returns a random node in the graph.
|
pure virtual |
Gets the root graph of the graph hierarchy.
|
virtual |
Finds the first node whose output degree equals 0.
|
virtual |
Finds the first node whose input degree equals 0.
|
pure virtual |
Returns a pointer on the subgraph with the corresponding id or nullptr if there is no subgraph with that id.
id | The id of the subgraph to retrieve. |
|
pure virtual |
Returns a pointer on the subgraph with the corresponding name or nullptr if there is no subgraph with that name.
name | The name of the subgraph to retrieve. |
Gets an iterator over all the subgraphs 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.
|
pure virtual |
Returns the parent of the graph. If called on the root graph, it returns itself.
|
pure virtual |
Get the input degree of a node.
n | The node to get the input degree of. |
Graph* tlp::Graph::inducedSubGraph | ( | const std::vector< node > & | nodes, |
Graph * | parentSubGraph = nullptr , |
||
const std::string & | name = "unnamed" |
||
) |
Creates and returns a new subgraph of the graph induced by a vector of nodes.
nodes | 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. |
name | The name of the newly created subgraph. |
Graph* tlp::Graph::inducedSubGraph | ( | const std::set< node > & | nodeSet, |
Graph * | parentSubGraph = nullptr , |
||
const std::string & | name = "unnamed" |
||
) |
deprecated, use inducedSubGraph(const std::set<node>&, Graph* = nullptr, const std::string& = "unamed") instead
Graph* tlp::Graph::inducedSubGraph | ( | BooleanProperty * | selection, |
Graph * | parentSubGraph = nullptr , |
||
const std::string & | name = "unnamed" |
||
) |
Creates and returns a new subgraph of the graph induced by a selection of nodes and edges.
selection | a selection of nodes and edges. |
parentSubGraph | If provided, is used as parent graph for the newly created subgraph instead of the graph this method is called on. |
name | The name of the newly created subgraph. |
|
pure virtual |
Indicates if the graph argument is a descendant of this graph.
subGraph | The graph to check is a descendant of this graph. |
|
pure virtual |
Checks if an element belongs to this graph.
n | The node to check if it is an element of the graph. |
|
pure virtual |
Checks if an element belongs to this graph.
e | The edge to check if it is an element of the graph. |
|
inlinevirtual |
|
pure virtual |
Checks if an edge is a meta edge.
e | The edge to check if it is a meta edge. |
|
pure virtual |
Checks if a node is a meta node.
n | The node to check if it is a meta node. |
|
pure virtual |
Indicates if the graph argument is a direct subgraph.
subGraph | The graph to check is a subgraph of this graph. |
|
pure virtual |
Return the position of a node in the vector of nodes of the graph.
n | The node for which the position is requested |
|
pure virtual |
Return a const reference on the vector of nodes of the graph It is the fastest way to access to nodes, Iterators are 25% slower.
|
pure virtual |
Return the number of descendant subgraphs. For instance, in the following graph hierarchy: root / \ A B /|\ C D E.
root->numberOfSubGraphs(); Will return 5.
|
pure virtual |
Gets the number of edges in this graph.
|
pure virtual |
Gets the number of nodes in this graph.
|
pure virtual |
Return the number of direct subgraphs. 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 |
Gets the opposite node of n through e.
e | The edge linking the two nodes. |
n | The node at one end of e. |
|
pure virtual |
Get the output degree of a node.
n | The node to get the output degree of. |
|
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. |
|
pure virtual |
abort last push if no updates have been recorded
|
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:
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(). |
|
inline |
|
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. |
|
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. |
|
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. |
|
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. |
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. |
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. |
|
pure virtual |
sort the graph elements in ascending order
Gets the source of an edge.
e | The edge to get the source of. |
|
pure virtual |
Return a const reference on the vector of subgraphs of the graph It is the fastest way to access to subgraphs, Iterators are 25% slower.
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. |
Gets the target of an edge.
e | The edge to get the target of. |
|
pure virtual |
Re-perform actions that were undone using pop().
For instance: