20 #ifndef Tulip_SUPERGRAPH_H
21 #define Tulip_SUPERGRAPH_H
28 #include <unordered_map>
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,
236 friend class GraphAbstract;
237 friend class GraphUpdatesRecorder;
238 friend class GraphDecorator;
239 friend class PropertyManager;
298 const std::string &name =
"unnamed") = 0;
321 bool addSiblingProperties =
false);
335 const std::string &name =
"unnamed");
351 const std::string &name =
"unnamed");
373 virtual void delSubGraph(
Graph *graph) = 0;
414 virtual void setSuperGraph(
Graph *) = 0;
436 virtual const std::vector<Graph *> &
subGraphs()
const = 0;
588 virtual void addNodes(
unsigned int nbNodes, std::vector<node> &addedNodes) = 0;
636 virtual void delNode(
const node n,
bool deleteInAllGraphs =
false) = 0;
658 void delNodes(
const std::vector<node> &nodes,
bool deleteInAllGraphs =
false);
680 virtual void addEdges(
const std::vector<std::pair<node, node>> &edges) = 0;
693 virtual void addEdges(
const std::vector<std::pair<node, node>> &edges,
694 std::vector<edge> &addedEdges) = 0;
737 virtual void delEdge(
const edge e,
bool deleteInAllGraphs =
false) = 0;
757 void delEdges(
const std::vector<edge> &edges,
bool deleteInAllGraphs =
false);
811 virtual void reserveNodes(
unsigned int nbNodes) = 0;
814 virtual void reserveEdges(
unsigned int nbEdges) = 0;
853 virtual const std::vector<node> &
nodes()
const = 0;
975 virtual const std::vector<edge> &
edges()
const = 0;
1076 return nodes().empty();
1132 virtual const std::pair<node, node> &
ends(
const edge e)
const = 0;
1178 return existEdge(source, target, directed).isValid();
1189 bool directed =
true)
const = 0;
1211 virtual void setName(
const std::string &name) = 0;
1226 return const_cast<Graph *
>(
this)->getNonConstAttributes();
1235 template <
typename ATTRIBUTETYPE>
1236 bool getAttribute(
const std::string &name, ATTRIBUTETYPE &value)
const;
1250 template <
typename ATTRIBUTETYPE>
1251 void setAttribute(
const std::string &name,
const ATTRIBUTETYPE &value);
1265 notifyRemoveAttribute(name);
1266 getNonConstAttributes().remove(name);
1275 return getAttributes().exists(name);
1311 template <
typename PropertyType>
1312 PropertyType *getLocalProperty(
const std::string &name);
1327 template <
typename PropertyType>
1328 PropertyType *getProperty(
const std::string &name);
1346 const std::string &propertyType);
1445 std::string &errorMessage,
DataSet *parameters =
nullptr,
1515 virtual void push(
bool unpopAllowed =
true,
1516 std::vector<PropertyInterface *> *propertiesToPreserveOnPop =
nullptr) = 0;
1523 virtual void pop(
bool unpopAllowed =
true) = 0;
1602 bool delAllEdge =
true,
bool allGrouped =
true);
1616 std::vector<node> &metaNodes,
bool inoutGrouped =
true);
1630 bool allGrouped =
true);
1646 virtual DataSet &getNonConstAttributes() = 0;
1649 virtual void restoreNode(
node) = 0;
1650 virtual void restoreEdge(
edge,
node source,
node target) = 0;
1653 virtual void removeNode(
const node) = 0;
1654 virtual void removeEdge(
const edge) = 0;
1659 return getRoot()->canDeleteProperty(g, prop);
1664 virtual bool renameLocalProperty(
PropertyInterface *prop,
const std::string &newName) = 0;
1667 virtual void removeSubGraph(
Graph *) = 0;
1668 virtual void clearSubGraphs() = 0;
1669 virtual void restoreSubGraph(
Graph *) = 0;
1670 virtual void setSubGraphToKeep(
Graph *) = 0;
1673 void notifyAddNode(
const node n);
1674 void notifyAddNode(
Graph *,
const node n) {
1677 void notifyAddEdge(
const edge e);
1678 void notifyAddEdge(Graph *,
const edge e) {
1681 void notifyBeforeSetEnds(
const edge e);
1682 void notifyBeforeSetEnds(Graph *,
const edge e) {
1683 notifyBeforeSetEnds(e);
1685 void notifyAfterSetEnds(
const edge e);
1686 void notifyAfterSetEnds(Graph *,
const edge e) {
1687 notifyAfterSetEnds(e);
1689 void notifyDelNode(
const node n);
1690 void notifyDelNode(Graph *,
const node n) {
1693 void notifyDelEdge(
const edge e);
1694 void notifyDelEdge(Graph *,
const edge e) {
1697 void notifyReverseEdge(
const edge e);
1698 void notifyReverseEdge(Graph *,
const edge e) {
1699 notifyReverseEdge(e);
1701 void notifyBeforeAddSubGraph(
const Graph *);
1702 void notifyAfterAddSubGraph(
const Graph *);
1703 void notifyBeforeAddSubGraph(Graph *,
const Graph *sg) {
1704 notifyBeforeAddSubGraph(sg);
1706 void notifyAfterAddSubGraph(Graph *,
const Graph *sg) {
1707 notifyAfterAddSubGraph(sg);
1709 void notifyBeforeDelSubGraph(
const Graph *);
1710 void notifyAfterDelSubGraph(
const Graph *);
1711 void notifyBeforeDelSubGraph(Graph *,
const Graph *sg) {
1712 notifyBeforeDelSubGraph(sg);
1714 void notifyAfterDelSubGraph(Graph *,
const Graph *sg) {
1715 notifyAfterDelSubGraph(sg);
1718 void notifyBeforeAddDescendantGraph(
const Graph *);
1719 void notifyAfterAddDescendantGraph(
const Graph *);
1720 void notifyBeforeDelDescendantGraph(
const Graph *);
1721 void notifyAfterDelDescendantGraph(
const Graph *);
1723 void notifyBeforeAddLocalProperty(
const std::string &);
1724 void notifyAddLocalProperty(
const std::string &);
1725 void notifyAddLocalProperty(Graph *,
const std::string &name) {
1726 notifyAddLocalProperty(name);
1728 void notifyBeforeDelLocalProperty(
const std::string &);
1729 void notifyAfterDelLocalProperty(
const std::string &);
1730 void notifyDelLocalProperty(Graph *,
const std::string &name) {
1731 notifyBeforeDelLocalProperty(name);
1733 void notifyBeforeSetAttribute(
const std::string &);
1734 void notifyBeforeSetAttribute(Graph *,
const std::string &name) {
1735 notifyBeforeSetAttribute(name);
1737 void notifyAfterSetAttribute(
const std::string &);
1738 void notifyAfterSetAttribute(Graph *,
const std::string &name) {
1739 notifyAfterSetAttribute(name);
1741 void notifyRemoveAttribute(
const std::string &);
1742 void notifyRemoveAttribute(Graph *,
const std::string &name) {
1743 notifyRemoveAttribute(name);
1745 void notifyDestroy();
1746 void notifyDestroy(Graph *) {
1751 std::unordered_map<std::string, tlp::PropertyInterface *> circularCalls;
1763 enum GraphEventType {
1768 TLP_REVERSE_EDGE = 4,
1769 TLP_BEFORE_SET_ENDS = 5,
1770 TLP_AFTER_SET_ENDS = 6,
1773 TLP_BEFORE_ADD_DESCENDANTGRAPH = 9,
1774 TLP_AFTER_ADD_DESCENDANTGRAPH = 10,
1775 TLP_BEFORE_DEL_DESCENDANTGRAPH = 11,
1776 TLP_AFTER_DEL_DESCENDANTGRAPH = 12,
1777 TLP_BEFORE_ADD_SUBGRAPH = 13,
1778 TLP_AFTER_ADD_SUBGRAPH = 14,
1779 TLP_BEFORE_DEL_SUBGRAPH = 15,
1780 TLP_AFTER_DEL_SUBGRAPH = 16,
1781 TLP_ADD_LOCAL_PROPERTY = 17,
1782 TLP_BEFORE_DEL_LOCAL_PROPERTY = 18,
1783 TLP_AFTER_DEL_LOCAL_PROPERTY = 19,
1784 TLP_ADD_INHERITED_PROPERTY = 20,
1785 TLP_BEFORE_DEL_INHERITED_PROPERTY = 21,
1786 TLP_AFTER_DEL_INHERITED_PROPERTY = 22,
1787 TLP_BEFORE_RENAME_LOCAL_PROPERTY = 23,
1788 TLP_AFTER_RENAME_LOCAL_PROPERTY = 24,
1789 TLP_BEFORE_SET_ATTRIBUTE = 25,
1790 TLP_AFTER_SET_ATTRIBUTE = 26,
1791 TLP_REMOVE_ATTRIBUTE = 27,
1792 TLP_BEFORE_ADD_LOCAL_PROPERTY = 28,
1793 TLP_BEFORE_ADD_INHERITED_PROPERTY = 29
1797 GraphEvent(
const Graph &g, GraphEventType graphEvtType,
unsigned int id,
1798 Event::EventType evtType = Event::TLP_MODIFICATION)
1799 :
Event(g, evtType), evtType(graphEvtType) {
1800 if (graphEvtType == TLP_ADD_NODES || graphEvtType == TLP_ADD_EDGES)
1805 vectInfos.addedNodes =
nullptr;
1809 :
Event(g, Event::TLP_MODIFICATION), evtType(graphEvtType) {
1811 vectInfos.addedNodes =
nullptr;
1815 GraphEvent(
const Graph &g, GraphEventType graphEvtType,
const std::string &str,
1816 Event::EventType evtType = Event::TLP_MODIFICATION)
1817 :
Event(g, evtType), evtType(graphEvtType) {
1818 info.name =
new std::string(str);
1819 vectInfos.addedNodes =
nullptr;
1824 const std::string &newName)
1825 :
Event(g, Event::TLP_MODIFICATION), evtType(graphEvtType) {
1826 info.renamedProp =
new std::pair<PropertyInterface *, std::string>(prop, newName);
1827 vectInfos.addedNodes =
nullptr;
1832 Graph *getGraph()
const {
1833 return static_cast<Graph *
>(sender());
1836 node getNode()
const {
1837 assert(evtType < TLP_ADD_EDGE);
1838 return node(info.eltId);
1841 edge getEdge()
const {
1842 assert(evtType > TLP_DEL_NODE && evtType < TLP_ADD_NODES);
1843 return edge(info.eltId);
1846 const std::vector<node> &getNodes()
const;
1848 unsigned int getNumberOfNodes()
const {
1849 assert(evtType == TLP_ADD_NODES);
1853 const std::vector<edge> &getEdges()
const;
1855 unsigned int getNumberOfEdges()
const {
1856 assert(evtType == TLP_ADD_EDGES);
1860 const Graph *getSubGraph()
const {
1861 assert(evtType > TLP_ADD_EDGES && evtType < TLP_ADD_LOCAL_PROPERTY);
1862 return info.subGraph;
1865 const std::string &getAttributeName()
const {
1866 assert(evtType > TLP_AFTER_DEL_INHERITED_PROPERTY);
1867 return *(info.name);
1870 const std::string &getPropertyName()
const;
1873 assert(evtType == TLP_BEFORE_RENAME_LOCAL_PROPERTY ||
1874 evtType == TLP_AFTER_RENAME_LOCAL_PROPERTY);
1875 return info.renamedProp->first;
1878 const std::string &getPropertyNewName()
const {
1879 assert(evtType == TLP_BEFORE_RENAME_LOCAL_PROPERTY);
1880 return info.renamedProp->second;
1883 const std::string &getPropertyOldName()
const {
1884 assert(evtType == TLP_AFTER_RENAME_LOCAL_PROPERTY);
1885 return info.renamedProp->second;
1888 GraphEventType getType()
const {
1893 GraphEventType evtType;
1896 const Graph *subGraph;
1898 unsigned int nbElts;
1899 std::pair<PropertyInterface *, std::string> *renamedProp;
1902 std::vector<node> *addedNodes;
1903 std::vector<edge> *addedEdges;
1909 TLP_SCOPE std::ostream &operator<<(std::ostream &,
const tlp::Graph *);
1911 #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.