20 #ifndef Tulip_SUPERGRAPH_H 
   21 #define Tulip_SUPERGRAPH_H 
   28 #include <tulip/tuliphash.h> 
   31 #include <tulip/tulipconf.h> 
   32 #include <tulip/DataSet.h> 
   33 #include <tulip/Node.h> 
   34 #include <tulip/Edge.h> 
   35 #include <tulip/Observable.h> 
   39 class PropertyInterface;
 
   40 class BooleanProperty;
 
  121 TLP_SCOPE 
bool exportGraph(
Graph *graph, std::ostream &outputStream, 
const std::string &format,
 
  170   virtual void graphImported(
Graph *g) = 0;
 
  251   friend class GraphAbstract;
 
  252   friend class GraphUpdatesRecorder;
 
  253   friend class GraphDecorator;
 
  254   friend class PropertyManager;
 
  313                              const std::string &name = 
"unnamed") = 0;
 
  336                                   bool addSiblingProperties = 
false);
 
  350                          const std::string &name = 
"unnamed");
 
  366                          const std::string &name = 
"unnamed");
 
  388   virtual void delSubGraph(
Graph *graph) = 0;
 
  429   virtual void setSuperGraph(
Graph *) = 0;
 
  451   virtual const std::vector<Graph *> &
subGraphs() 
const = 0;
 
  603   virtual void addNodes(
unsigned int nbNodes, std::vector<node> &addedNodes) = 0;
 
  651   virtual void delNode(
const node n, 
bool deleteInAllGraphs = 
false) = 0;
 
  673   void delNodes(
const std::vector<node> &nodes, 
bool deleteInAllGraphs = 
false);
 
  695   virtual void addEdges(
const std::vector<std::pair<node, node>> &edges) = 0;
 
  708   virtual void addEdges(
const std::vector<std::pair<node, node>> &edges,
 
  709                         std::vector<edge> &addedEdges) = 0;
 
  752   virtual void delEdge(
const edge e, 
bool deleteInAllGraphs = 
false) = 0;
 
  772   void delEdges(
const std::vector<edge> &edges, 
bool deleteInAllGraphs = 
false);
 
  826   virtual void reserveNodes(
unsigned int nbNodes) = 0;
 
  829   virtual void reserveEdges(
unsigned int nbEdges) = 0;
 
  868   virtual const std::vector<node> &
nodes() 
const = 0;
 
  990   virtual const std::vector<edge> &
edges() 
const = 0;
 
 1091     return nodes().empty();
 
 1147   virtual const std::pair<node, node> &
ends(
const edge e) 
const = 0;
 
 1193     return existEdge(source, target, directed).isValid();
 
 1204                                      bool directed = 
true) 
const = 0;
 
 1226   virtual void setName(
const std::string &name) = 0;
 
 1241     return const_cast<Graph *
>(
this)->getNonConstAttributes();
 
 1250   template <
typename ATTRIBUTETYPE>
 
 1251   bool getAttribute(
const std::string &name, ATTRIBUTETYPE &value) 
const;
 
 1265   template <
typename ATTRIBUTETYPE>
 
 1266   void setAttribute(
const std::string &name, 
const ATTRIBUTETYPE &value);
 
 1280     notifyRemoveAttribute(name);
 
 1281     getNonConstAttributes().remove(name);
 
 1290     return getAttributes().exists(name);
 
 1326   template <
typename PropertyType>
 
 1327   PropertyType *getLocalProperty(
const std::string &name);
 
 1342   template <
typename PropertyType>
 
 1343   PropertyType *getProperty(
const std::string &name);
 
 1361                                       const std::string &propertyType);
 
 1460                               std::string &errorMessage, 
DataSet *parameters = 
nullptr,
 
 1530   virtual void push(
bool unpopAllowed = 
true,
 
 1531                     std::vector<PropertyInterface *> *propertiesToPreserveOnPop = 
nullptr) = 0;
 
 1538   virtual void pop(
bool unpopAllowed = 
true) = 0;
 
 1617                               bool delAllEdge = 
true, 
bool allGrouped = 
true);
 
 1631                                std::vector<node> &metaNodes, 
bool inoutGrouped = 
true);
 
 1645                               bool allGrouped = 
true);
 
 1661   virtual DataSet &getNonConstAttributes() = 0;
 
 1664   virtual void restoreNode(
node) = 0;
 
 1665   virtual void restoreEdge(
edge, 
node source, 
node target) = 0;
 
 1668   virtual void removeNode(
const node) = 0;
 
 1669   virtual void removeEdge(
const edge) = 0;
 
 1674     return getRoot()->canDeleteProperty(g, prop);
 
 1679   virtual bool renameLocalProperty(
PropertyInterface *prop, 
const std::string &newName) = 0;
 
 1682   virtual void removeSubGraph(
Graph *) = 0;
 
 1683   virtual void clearSubGraphs() = 0;
 
 1684   virtual void restoreSubGraph(
Graph *) = 0;
 
 1685   virtual void setSubGraphToKeep(
Graph *) = 0;
 
 1688   void notifyAddNode(
const node n);
 
 1689   void notifyAddNode(
Graph *, 
const node n) {
 
 1692   void notifyAddEdge(
const edge e);
 
 1693   void notifyAddEdge(Graph *, 
const edge e) {
 
 1696   void notifyBeforeSetEnds(
const edge e);
 
 1697   void notifyBeforeSetEnds(Graph *, 
const edge e) {
 
 1698     notifyBeforeSetEnds(e);
 
 1700   void notifyAfterSetEnds(
const edge e);
 
 1701   void notifyAfterSetEnds(Graph *, 
const edge e) {
 
 1702     notifyAfterSetEnds(e);
 
 1704   void notifyBeforeDelNode(
const node n);
 
 1705   void notifyBeforeDelNode(Graph *, 
const node n) {
 
 1706     notifyBeforeDelNode(n);
 
 1708   void notifyAfterDelNode(
const node n);
 
 1709   void notifyAfterDelNode(Graph *, 
const node n) {
 
 1710     notifyAfterDelNode(n);
 
 1712   void notifyBeforeDelEdge(
const edge e);
 
 1713   void notifyBeforeDelEdge(Graph *, 
const edge e) {
 
 1714     notifyBeforeDelEdge(e);
 
 1716   void notifyAfterDelEdge(
const edge e);
 
 1717   void notifyAfterDelEdge(Graph *, 
const edge e) {
 
 1718     notifyAfterDelEdge(e);
 
 1720   void notifyReverseEdge(
const edge e);
 
 1721   void notifyReverseEdge(Graph *, 
const edge e) {
 
 1722     notifyReverseEdge(e);
 
 1724   void notifyBeforeAddSubGraph(
const Graph *);
 
 1725   void notifyAfterAddSubGraph(
const Graph *);
 
 1726   void notifyBeforeAddSubGraph(Graph *, 
const Graph *sg) {
 
 1727     notifyBeforeAddSubGraph(sg);
 
 1729   void notifyAfterAddSubGraph(Graph *, 
const Graph *sg) {
 
 1730     notifyAfterAddSubGraph(sg);
 
 1732   void notifyBeforeDelSubGraph(
const Graph *);
 
 1733   void notifyAfterDelSubGraph(
const Graph *);
 
 1734   void notifyBeforeDelSubGraph(Graph *, 
const Graph *sg) {
 
 1735     notifyBeforeDelSubGraph(sg);
 
 1737   void notifyAfterDelSubGraph(Graph *, 
const Graph *sg) {
 
 1738     notifyAfterDelSubGraph(sg);
 
 1741   void notifyBeforeAddDescendantGraph(
const Graph *);
 
 1742   void notifyAfterAddDescendantGraph(
const Graph *);
 
 1743   void notifyBeforeDelDescendantGraph(
const Graph *);
 
 1744   void notifyAfterDelDescendantGraph(
const Graph *);
 
 1746   void notifyBeforeAddLocalProperty(
const std::string &);
 
 1747   void notifyAddLocalProperty(
const std::string &);
 
 1748   void notifyAddLocalProperty(Graph *, 
const std::string &name) {
 
 1749     notifyAddLocalProperty(name);
 
 1751   void notifyBeforeDelLocalProperty(
const std::string &);
 
 1752   void notifyAfterDelLocalProperty(
const std::string &);
 
 1753   void notifyDelLocalProperty(Graph *, 
const std::string &name) {
 
 1754     notifyBeforeDelLocalProperty(name);
 
 1756   void notifyBeforeSetAttribute(
const std::string &);
 
 1757   void notifyBeforeSetAttribute(Graph *, 
const std::string &name) {
 
 1758     notifyBeforeSetAttribute(name);
 
 1760   void notifyAfterSetAttribute(
const std::string &);
 
 1761   void notifyAfterSetAttribute(Graph *, 
const std::string &name) {
 
 1762     notifyAfterSetAttribute(name);
 
 1764   void notifyRemoveAttribute(
const std::string &);
 
 1765   void notifyRemoveAttribute(Graph *, 
const std::string &name) {
 
 1766     notifyRemoveAttribute(name);
 
 1768   void notifyDestroy();
 
 1769   void notifyDestroy(Graph *) {
 
 1774   tlp_hash_map<std::string, tlp::PropertyInterface *> circularCalls;
 
 1786   enum GraphEventType {
 
 1788     TLP_BEFORE_DEL_NODE,
 
 1791     TLP_BEFORE_DEL_EDGE,
 
 1794     TLP_BEFORE_SET_ENDS,
 
 1798     TLP_BEFORE_ADD_DESCENDANTGRAPH,
 
 1799     TLP_AFTER_ADD_DESCENDANTGRAPH,
 
 1800     TLP_BEFORE_DEL_DESCENDANTGRAPH,
 
 1801     TLP_AFTER_DEL_DESCENDANTGRAPH,
 
 1802     TLP_BEFORE_ADD_SUBGRAPH,
 
 1803     TLP_AFTER_ADD_SUBGRAPH,
 
 1804     TLP_BEFORE_DEL_SUBGRAPH,
 
 1805     TLP_AFTER_DEL_SUBGRAPH,
 
 1806     TLP_ADD_LOCAL_PROPERTY,
 
 1807     TLP_BEFORE_DEL_LOCAL_PROPERTY,
 
 1808     TLP_AFTER_DEL_LOCAL_PROPERTY,
 
 1809     TLP_ADD_INHERITED_PROPERTY,
 
 1810     TLP_BEFORE_DEL_INHERITED_PROPERTY,
 
 1811     TLP_AFTER_DEL_INHERITED_PROPERTY,
 
 1812     TLP_BEFORE_RENAME_LOCAL_PROPERTY,
 
 1813     TLP_AFTER_RENAME_LOCAL_PROPERTY,
 
 1814     TLP_BEFORE_SET_ATTRIBUTE,
 
 1815     TLP_AFTER_SET_ATTRIBUTE,
 
 1816     TLP_REMOVE_ATTRIBUTE,
 
 1817     TLP_BEFORE_ADD_LOCAL_PROPERTY,
 
 1818     TLP_BEFORE_ADD_INHERITED_PROPERTY
 
 1822   GraphEvent(
const Graph &g, GraphEventType graphEvtType, 
unsigned int id,
 
 1823              Event::EventType evtType = Event::TLP_MODIFICATION)
 
 1824       : 
Event(g, evtType), evtType(graphEvtType) {
 
 1825     if (graphEvtType == TLP_ADD_NODES || graphEvtType == TLP_ADD_EDGES)
 
 1830     vectInfos.addedNodes = 
nullptr;
 
 1834       : 
Event(g, Event::TLP_MODIFICATION), evtType(graphEvtType) {
 
 1836     vectInfos.addedNodes = 
nullptr;
 
 1840   GraphEvent(
const Graph &g, GraphEventType graphEvtType, 
const std::string &str,
 
 1841              Event::EventType evtType = Event::TLP_MODIFICATION)
 
 1842       : 
Event(g, evtType), evtType(graphEvtType) {
 
 1843     info.name = 
new std::string(str);
 
 1844     vectInfos.addedNodes = 
nullptr;
 
 1849              const std::string &newName)
 
 1850       : 
Event(g, Event::TLP_MODIFICATION), evtType(graphEvtType) {
 
 1851     info.renamedProp = 
new std::pair<PropertyInterface *, std::string>(prop, newName);
 
 1852     vectInfos.addedNodes = 
nullptr;
 
 1857   Graph *getGraph()
 const {
 
 1858     return static_cast<Graph *
>(sender());
 
 1861   node getNode()
 const {
 
 1862     assert(evtType < TLP_ADD_EDGE);
 
 1863     return node(info.eltId);
 
 1866   edge getEdge()
 const {
 
 1867     assert(evtType > TLP_AFTER_DEL_NODE && evtType < TLP_ADD_NODES);
 
 1868     return edge(info.eltId);
 
 1871   const std::vector<node> &getNodes() 
const;
 
 1873   unsigned int getNumberOfNodes()
 const {
 
 1874     assert(evtType == TLP_ADD_NODES);
 
 1878   const std::vector<edge> &getEdges() 
const;
 
 1880   unsigned int getNumberOfEdges()
 const {
 
 1881     assert(evtType == TLP_ADD_EDGES);
 
 1885   const Graph *getSubGraph()
 const {
 
 1886     assert(evtType > TLP_ADD_EDGES && evtType < TLP_ADD_LOCAL_PROPERTY);
 
 1887     return info.subGraph;
 
 1890   const std::string &getAttributeName()
 const {
 
 1891     assert(evtType > TLP_AFTER_DEL_INHERITED_PROPERTY);
 
 1892     return *(info.name);
 
 1895   const std::string &getPropertyName() 
const;
 
 1898     assert(evtType == TLP_BEFORE_RENAME_LOCAL_PROPERTY ||
 
 1899            evtType == TLP_AFTER_RENAME_LOCAL_PROPERTY);
 
 1900     return info.renamedProp->first;
 
 1903   const std::string &getPropertyNewName()
 const {
 
 1904     assert(evtType == TLP_BEFORE_RENAME_LOCAL_PROPERTY);
 
 1905     return info.renamedProp->second;
 
 1908   const std::string &getPropertyOldName()
 const {
 
 1909     assert(evtType == TLP_AFTER_RENAME_LOCAL_PROPERTY);
 
 1910     return info.renamedProp->second;
 
 1913   GraphEventType getType()
 const {
 
 1918   GraphEventType evtType;
 
 1921     const Graph *subGraph;
 
 1923     unsigned int nbElts;
 
 1924     std::pair<PropertyInterface *, std::string> *renamedProp;
 
 1927     std::vector<node> *addedNodes;
 
 1928     std::vector<edge> *addedEdges;
 
 1934 TLP_SCOPE std::ostream &operator<<(std::ostream &, 
const tlp::Graph *);
 
 1936 #include "cxx/Graph.cxx" 
A graph property that maps a Boolean value to graph elements.
 
A container that can store data from any type.
 
Event is the base class for all events used in the Observation mechanism.
 
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.
 
virtual bool isDescendantGraph(const Graph *subGraph) const =0
Indicates if the graph argument is a descendant of this graph.
 
virtual bool isMetaEdge(const edge e) const =0
Checks if an edge is a meta edge.
 
virtual unsigned int edgePos(const edge e) const =0
Return the position of an edge in the vector of edges of the graph.
 
virtual Graph * getSubGraph(const std::string &name) const =0
Returns a pointer on the subgraph with the corresponding name or nullptr if there is no subgraph with...
 
virtual std::vector< edge > getEdges(const node source, const node target, bool directed=true) const =0
Returns all the edges between two nodes.
 
virtual edge getOneEdge() const =0
Returns the first edge in the graph.
 
void openMetaNode(node n, bool updateProperties=true)
Opens a metanode and replaces all edges between that meta node and other nodes in the graph.
 
virtual node createMetaNode(Graph *subGraph, bool multiEdges=true, bool delAllEdge=true, bool allGrouped=true)
Closes an existing subgraph into a metanode. Edges from nodes in the subgraph to nodes outside the su...
 
virtual const std::vector< node > & nodes() const =0
Return a const reference on the vector of nodes of the graph It is the fastest way to access to nodes...
 
virtual Graph * addCloneSubGraph(const std::string &name="unnamed", bool addSibling=false, bool addSiblingProperties=false)
Creates and returns a subgraph that contains all the elements of this graph.
 
void setAttribute(const std::string &name, const DataType *value)
Sets an attribute on the graph.
 
Iterator< Graph * > * getDescendantGraphs() const
Gets an iterator over all the descendant subgraphs of the graph. For instance, in the following graph...
 
virtual void addNodes(Iterator< node > *nodes)=0
Adds existing nodes in the graph. The nodes are also added in all the ancestor graphs....
 
virtual Iterator< std::string > * getProperties() const =0
Gets an iterator over the names of all the properties attached to this graph, whether they are local ...
 
virtual Iterator< std::string > * getInheritedProperties() const =0
Gets an iterator over the names of the properties inherited from this graph's ancestors,...
 
PropertyInterface * 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...
 
virtual Iterator< node > * dfs(const node root=node()) const =0
Gets an iterator performing a depth-first search on the graph.
 
virtual node source(const edge e) const =0
Gets the source of an edge.
 
virtual tlp::node getSource() const
Finds the first node whose input degree equals 0.
 
virtual bool isSubGraph(const Graph *subGraph) const =0
Indicates if the graph argument is a direct subgraph.
 
bool existAttribute(const std::string &name) const
Checks if an attribute exists.
 
virtual bool isElement(const edge e) const =0
Checks if an element belongs to this graph.
 
virtual edge getRandomEdge() const =0
Returns a random edge in the graph.
 
virtual bool canPopThenUnpop()=0
Checks if it is possible to call pop() and then unPop(), to undo then re-do modifications.
 
virtual node target(const edge e) const =0
Gets the target of an edge.
 
virtual unsigned int nodePos(const node n) const =0
Return the position of a node in the vector of nodes of the graph.
 
virtual const std::vector< edge > & allEdges(const node n) const =0
Gets all input/output edges of a node existing in the root graph.
 
virtual Graph * getRoot() const =0
Gets the root graph of the graph hierarchy.
 
virtual void clear()=0
Removes all nodes, edges and subgraphs from this graph.
 
virtual void setSource(const edge e, const node source)=0
Sets the source of an edge to be the given node.
 
virtual Iterator< node > * bfs(const node root=node()) const =0
Gets an iterator performing a breadth-first search on the graph.
 
virtual Iterator< Graph * > * getSubGraphs() const =0
Gets an iterator over all the subgraphs of the graph. For instance, in the following graph hierarchy:...
 
virtual std::string getName() const =0
Retrieves the name of the graph.
 
void addEdges(const std::vector< edge > &edges)
Adds existing edges in the graph. The edges are also added in all the ancestor graphs....
 
virtual Iterator< edge > * getEdges() const =0
Get an iterator over all the graph's edges.
 
virtual Iterator< edge > * getOutEdges(const node n) const =0
Gets an iterator over the output edges of a node.
 
virtual void addEdges(const std::vector< std::pair< node, node >> &edges)=0
Adds new edges in the graph. The new edges are also added in all graph ancestors.
 
virtual PropertyInterface * getProperty(const std::string &name) const =0
Gets an existing property. In DEBUG mode an assertion checks the existence of the property.
 
virtual const std::vector< edge > & edges() const =0
Return a const reference on the vector of edges of the graph It is the fastest way to access to edges...
 
virtual bool isElement(const node n) const =0
Checks if an element belongs to this graph.
 
virtual void setEnds(const edge e, const node source, const node target)=0
Sets both the source and the target of an edge.
 
virtual unsigned int numberOfNodes() const =0
Gets the number of nodes in this graph.
 
virtual void push(bool unpopAllowed=true, std::vector< PropertyInterface * > *propertiesToPreserveOnPop=nullptr)=0
Saves the current state of the whole graph hierarchy and allows to revert to this state later on,...
 
virtual Iterator< edge > * getInOutEdges(const node n) const =0
Gets an iterator over the edges of a node.
 
unsigned int getId() const
Gets the unique identifier of the graph.
 
virtual bool canPop()=0
Checks if there is a state to revert to.
 
virtual edge addEdge(const node source, const node target)=0
Adds a new edge in the graph This edge is also added in all the super-graph of the graph.
 
virtual Graph * getSubGraph(unsigned int id) const =0
Returns a pointer on the subgraph with the corresponding id or nullptr if there is no subgraph with t...
 
virtual void setTarget(const edge e, const node target)=0
Sets the target of an edge to be the given node.
 
virtual bool existLocalProperty(const std::string &name) const =0
Checks if a property exists in this graph.
 
virtual node opposite(const edge e, const node n) const =0
Gets the opposite node of n through e.
 
virtual Graph * addSubGraph(BooleanProperty *selection=nullptr, const std::string &name="unnamed")=0
Creates and returns a new subgraph of this graph.
 
virtual bool isEmpty() const
return whether the graph is empty or not.
 
virtual Iterator< node > * getNodes() const =0
Gets an iterator over this graph's nodes.
 
void addNodes(const std::vector< node > &nodes)
Adds existing nodes in the graph. The nodes are also added in all the ancestor graphs....
 
virtual Iterator< PropertyInterface * > * getInheritedObjectProperties() const =0
Gets an iterator over the properties inherited from this graph's ancestors, excluding this graph's lo...
 
virtual unsigned int numberOfEdges() const =0
Gets the number of edges in this graph.
 
virtual void setEdgeOrder(const node n, const std::vector< edge > &edges)=0
Sets the order of the edges around a node. This operation ensures that adjacent edges of a node will ...
 
virtual void addEdges(const std::vector< std::pair< node, node >> &edges, std::vector< edge > &addedEdges)=0
Adds new edges in the graph and returns them in the addedEdges vector. The new edges are also added i...
 
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.
 
virtual void createMetaNodes(Iterator< Graph * > *itS, Graph *quotientGraph, std::vector< node > &metaNodes, bool inoutGrouped=true)
Populates a quotient graph with one meta node for each iterated graph.
 
virtual node getOutNode(const node n, unsigned int i) const =0
Gets the i-th node in the output nodes of a given node. An output node 'out' of a node 'N' is the tar...
 
virtual void reverse(const edge e)=0
Reverses the direction of an edge, the source becomes the target and the target becomes the source.
 
virtual void delEdges(Iterator< edge > *itE, bool deleteInAllGraphs=false)=0
Deletes edges in the graph. These edges are also removed in the subgraphs hierarchy....
 
virtual void addNodes(unsigned int nbNodes)=0
Adds new nodes in the graph. The new nodes are also added in all the ancestor graphs.
 
virtual node addNode()=0
Adds a new node in the graph and returns it. This node is also added in all the ancestor graphs.
 
const DataSet & getAttributes() const
Gets the attributes of the graph.
 
virtual Iterator< PropertyInterface * > * getObjectProperties() const =0
Gets an iterator over the properties attached to this graph, whether they are local or inherited.
 
virtual unsigned int indeg(const node n) const =0
Get the input degree of a node.
 
virtual node getInNode(const node n, unsigned int i) const =0
Gets the i-th node in the input nodes of a given node. An input node 'in' of a node 'N' is the source...
 
virtual Graph * getNodeMetaInfo(const node metaNode) const =0
Gets the underlying graph of a meta node.
 
virtual void delEdge(const edge e, bool deleteInAllGraphs=false)=0
Deletes an edge in the graph. The edge is also removed in the subgraphs hierarchy....
 
virtual Iterator< node > * getInNodes(const node n) const =0
Gets an iterator over the input nodes of a node.
 
virtual unsigned int deg(const node n) const =0
 
virtual node getRandomNode() const =0
Returns a random node in the graph.
 
virtual bool hasEdge(const node source, const node target, bool directed=true) const
Checks if an edge exists between two given nodes.
 
virtual void pop(bool unpopAllowed=true)=0
Undoes modifications and reverts the whole graph hierarchy back to a previous state.
 
void delEdges(const std::vector< edge > &edges, bool deleteInAllGraphs=false)
Deletes edges in the graph. These edges are also removed in the subgraphs hierarchy....
 
virtual unsigned int numberOfDescendantGraphs() const =0
Return the number of descendant subgraphs. For instance, in the following graph hierarchy: root / \ A...
 
PropertyInterface * 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...
 
virtual Graph * getNthSubGraph(unsigned int n) const
This method returns the nth subgraph. Since subgraphs order cannot be ensured in every implementation...
 
DataType * getAttribute(const std::string &name) const
Gets a copy of the attribute.
 
virtual void addEdges(Iterator< edge > *edges)=0
Adds existing edges in the graph. The edges are also added in all the ancestor graphs....
 
Graph * addSubGraph(const std::string &name)
Creates and returns a new named subgraph of this graph.
 
virtual Graph * getDescendantGraph(unsigned int id) const =0
Returns a pointer on the descendant with the corresponding id or nullptr if there is no descendant wi...
 
virtual void setName(const std::string &name)=0
Sets the name of the graph. The name does not have to be unique, it is used for convenience.
 
virtual Iterator< node > * getOutNodes(const node n) const =0
Gets an iterator over the output nodes of a node.
 
virtual Graph * getDescendantGraph(const std::string &name) const =0
Returns a pointer on the first descendant graph with the corresponding name or nullptr if there is no...
 
virtual Iterator< node > * getInOutNodes(const node n) const =0
Gets an iterator over the neighbors of a given node.
 
virtual void popIfNoUpdates()=0
abort last push if no updates have been recorded
 
virtual node createMetaNode(const std::vector< node > &nodes, bool multiEdges=true, bool delAllEdge=true, bool allGrouped=true)
Creates a meta-node from a vector of nodes. Every edges from any node in the vector to another node o...
 
virtual Iterator< edge > * getInEdges(const node n) const =0
Gets an iterator over the input edges of a node.
 
virtual edge existEdge(const node source, const node target, bool directed=true) const =0
Returns the first edge found between the two given nodes.
 
virtual tlp::node getSink() const
Finds the first node whose output degree equals 0.
 
virtual void unpop()=0
Re-perform actions that were undone using pop().
 
virtual void delNode(const node n, bool deleteInAllGraphs=false)=0
Deletes a node in the graph. This node is also removed in the subgraphs hierarchy of the current grap...
 
virtual void addNode(const node n)=0
Adds an existing node in the graph. This node is also added in all the ancestor graphs....
 
void removeAttribute(const std::string &name)
Removes an attribute on the graph.
 
virtual const std::vector< Graph * > & subGraphs() const =0
Return a const reference on the vector of subgraphs of the graph It is the fastest way to access to s...
 
virtual bool canUnpop()=0
Checks if the last undone modifications can be redone.
 
virtual void delNodes(Iterator< node > *it, bool deleteInAllGraphs=false)=0
Deletes nodes in the graph. These nodes are also removed in the subgraphs hierarchy of the current gr...
 
virtual void addEdge(const edge e)=0
Adds an existing edge in the graph. This edge is also added in all the ancestor graphs....
 
virtual node getOneNode() const =0
Returns the first node in the graph.
 
virtual Graph * getSuperGraph() const =0
Returns the parent of the graph. If called on the root graph, it returns itself.
 
virtual void addLocalProperty(const std::string &name, PropertyInterface *prop)=0
Adds a property to the graph. The graph takes ownership of the property. If you want to delete it,...
 
virtual Iterator< PropertyInterface * > * getLocalObjectProperties() const =0
Gets an iterator over the local properties of this graph.
 
virtual void sortElts()=0
sort the graph elements in ascending order
 
virtual unsigned int numberOfSubGraphs() const =0
Return the number of direct subgraphs. For instance, in the following graph hierarchy: root / \ A B /...
 
virtual unsigned int outdeg(const node n) const =0
Get the output degree of a node.
 
virtual bool isMetaNode(const node n) const =0
Checks if a node is a meta node.
 
bool 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::Alg...
 
virtual void addNodes(unsigned int nbNodes, std::vector< node > &addedNodes)=0
Adds new nodes in the graph and returns them in the addedNodes vector. The new nodes are also added i...
 
void 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 gr...
 
virtual void swapEdgeOrder(const node n, const edge e1, const edge e2)=0
Swaps two edges in the adjacency list of a node.
 
bool 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.
 
virtual void delLocalProperty(const std::string &name)=0
Removes and deletes a property from this graph. The property is removed from the graph's property poo...
 
virtual Iterator< edge > * getEdgeMetaInfo(const edge metaEdge) const =0
Gets an iterator over the edges composing a meta edge.
 
virtual Iterator< std::string > * getLocalProperties() const =0
Gets an iterator over the names of the local properties of this graph.
 
virtual void delAllSubGraphs(Graph *graph=nullptr)=0
Deletes a subgraph of this graph. All subgraphs of the removed graph are re-parented to this graph....
 
virtual bool existProperty(const std::string &name) const =0
Checks if a property exists in this graph or one of its ancestors.
 
virtual const std::pair< node, node > & ends(const edge e) const =0
Gets the source and the target of an edge.
 
The Observable class is the base of Tulip's observation system.
 
PluginProcess subclasses are meant to notify about the progress state of some process (typically a pl...
 
PropertyInterface describes the interface of a graph property.
 
void removeFromGraph(Graph *ioG, BooleanProperty *inSelection=nullptr)
 
Graph * newGraph()
Creates a new, empty graph.
 
bool saveGraph(Graph *graph, const std::string &filename, tlp::PluginProgress *progress=nullptr, tlp::DataSet *data=nullptr)
Saves the corresponding graph to a file (extension can be any of the Tulip supported output graph fil...
 
Iterator< Graph * > * getRootGraphs()
 
void copyToGraph(Graph *outG, const Graph *inG, BooleanProperty *inSelection=nullptr, BooleanProperty *outSelection=nullptr)
 
Graph * importGraph(const std::string &format, DataSet &dataSet, PluginProgress *progress=nullptr, Graph *newGraph=nullptr)
Imports a graph using the specified import plugin with the parameters stored in the DataSet.
 
bool exportGraph(Graph *graph, std::ostream &outputStream, const std::string &format, DataSet &dataSet, PluginProgress *progress=nullptr)
Exports a graph using the specified export plugin with parameters stored in the DataSet.
 
Graph * loadGraph(const std::string &filename, tlp::PluginProgress *progress=nullptr)
Loads a graph from a file (extension can be any of the Tulip supported input graph file format).
 
Describes a value of any type.
 
Interface for Tulip iterators. Allows basic iteration operations only.
 
The edge struct represents an edge in a Graph object.
 
The node struct represents a node in a Graph object.