21 #ifndef DOXYGEN_NOTFOR_DEVEL
23 #ifndef Tulip_GraphDecorator_H
24 #define Tulip_GraphDecorator_H
26 #include <tulip/Graph.h>
30 class TLP_SCOPE GraphDecorator :
public Graph {
32 GraphDecorator(Graph* s);
33 virtual ~GraphDecorator();
36 virtual Graph *addSubGraph(BooleanProperty *selection=0,
37 const std::string& name =
"unnamed");
38 virtual void delSubGraph(Graph * s);
39 virtual void delAllSubGraphs(Graph *s);
40 virtual Graph* getSuperGraph()
const;
41 virtual void setSuperGraph(Graph* s);
42 virtual Graph* getRoot()
const;
43 virtual Iterator<Graph *> * getSubGraphs()
const;
44 virtual bool isSubGraph(
const Graph* sg)
const;
45 virtual bool isDescendantGraph(
const Graph* sg)
const;
46 virtual Graph* getSubGraph(
unsigned int id)
const;
47 virtual Graph* getSubGraph(
const std::string &name)
const;
48 virtual Graph* getDescendantGraph(
unsigned int id)
const;
49 virtual Graph* getDescendantGraph(
const std::string &name)
const;
50 virtual unsigned int numberOfSubGraphs()
const;
51 virtual unsigned int numberOfDescendantGraphs()
const;
54 virtual node source(
const edge e)
const;
55 virtual void setSource(
const edge,
const node);
56 virtual node target(
const edge e)
const;
57 virtual void setTarget(
const edge,
const node);
58 virtual node opposite(
const edge e,
const node n)
const;
59 virtual edge existEdge(
const node n,
const node m,
bool directed =
true)
const;
60 virtual bool hasEdge(
const node source,
const node target,
61 bool directed =
true)
const;
62 virtual std::vector<edge> getEdges(
const node source,
const node target,
63 bool directed =
true)
const;
64 virtual const std::pair<node, node>& ends(
const edge e)
const;
65 virtual void setEnds(
const edge,
const node,
const node);
66 virtual void reverse(
const edge e);
67 virtual unsigned int deg(
const node n)
const;
68 virtual unsigned int indeg(
const node n)
const;
69 virtual unsigned int outdeg(
const node n)
const;
70 virtual Graph* getNodeMetaInfo(
const node n)
const;
73 virtual node createMetaNode(
const std::set<node> &nodeSet,
bool multiEdges =
true,
bool delAllEdge =
true);
74 virtual void createMetaNodes(Iterator<Graph *> *itS, Graph *quotientGraph, std::vector<node>& metaNodes);
75 virtual node createMetaNode(Graph* subGraph,
bool multiEdges =
true,
bool delAllEdge =
true);
78 virtual node getOneNode()
const;
79 virtual node getRandomNode()
const;
80 virtual node getInNode(
const node n,
unsigned int i)
const;
81 virtual node getOutNode(
const node n,
unsigned int i)
const;
82 virtual edge getOneEdge()
const;
83 virtual edge getRandomEdge()
const;
85 virtual unsigned int numberOfNodes()
const;
86 virtual unsigned int numberOfEdges()
const;
90 virtual void reserveNodes(
unsigned int nbNodes);
91 virtual void reserveEdges(
unsigned int nbEdges);
94 virtual bool isElement(
const node n)
const;
95 virtual bool isMetaNode(
const node n)
const;
96 virtual bool isElement(
const edge e)
const;
97 virtual bool isMetaEdge(
const edge e)
const;
98 virtual node addNode();
99 virtual void addNodes(
unsigned int nb, std::vector<node>& addedNodes);
100 virtual void addNode(
const node);
101 virtual void addNodes(Iterator<node>* nodes);
102 virtual edge addEdge(
const node n1,
const node n2);
103 virtual void addEdges(
const std::vector<std::pair<node, node> >& edges,
104 std::vector<edge>& addedEdges);
105 virtual void addEdge(
const edge);
106 virtual void addEdges(Iterator<edge>* edges);
107 virtual void delNode(
const tlp::node n,
bool deleteInAllGraphs =
false);
108 virtual void delNodes(Iterator<node>* itN,
bool deleteInAllGraphs);
109 virtual void delEdge(
const tlp::edge e,
bool deleteInAllGraphs =
false);
110 virtual void delEdges(Iterator<edge>* itE,
bool deleteInAllGraphs =
false);
111 virtual void setEdgeOrder(
const node n,
const std::vector<edge> & s);
112 virtual void swapEdgeOrder(
const node n ,
const edge e1,
const edge e2);
114 virtual Iterator<node>* getNodes()
const;
115 virtual Iterator<node>* getInNodes(
const node n)
const;
116 virtual Iterator<node>* getOutNodes(
const node n)
const;
117 virtual Iterator<node>* getInOutNodes(
const node n)
const;
118 virtual Iterator<node>* bfs(
const node root = node())
const;
119 virtual Iterator<node>* dfs(
const node root = node())
const;
120 virtual Iterator<edge>* getEdges()
const;
121 virtual Iterator<edge>* getOutEdges(
const node n)
const;
122 virtual Iterator<edge>* getInOutEdges(
const node n)
const;
123 virtual Iterator<edge>* getInEdges(
const node n)
const;
124 virtual Iterator<edge>* getEdgeMetaInfo(
const edge)
const;
126 template<
typename PropertyType>
127 PropertyType* getProperty(
const std::string &name);
128 virtual PropertyInterface* getProperty(
const std::string &name)
const;
129 virtual bool existProperty(
const std::string&name)
const;
130 virtual bool existLocalProperty(
const std::string&name)
const;
131 virtual void delLocalProperty(
const std::string&name);
132 virtual void addLocalProperty(
const std::string &name, PropertyInterface *prop);
133 virtual Iterator<std::string>* getLocalProperties()
const;
134 virtual Iterator<std::string>* getInheritedProperties()
const;
135 virtual Iterator<std::string>* getProperties()
const;
136 virtual Iterator<PropertyInterface*>* getLocalObjectProperties()
const;
137 virtual Iterator<PropertyInterface*>* getInheritedObjectProperties()
const;
138 virtual Iterator<PropertyInterface*>* getObjectProperties()
const;
140 virtual void push(
bool unpopAllowed =
true,
141 std::vector<PropertyInterface*>* propertiesToPreserveOnPop= NULL);
142 virtual void pop(
bool unpopAllowed =
true);
143 virtual void unpop();
144 virtual bool canPop();
145 virtual bool canUnpop();
146 virtual bool canPopThenUnpop();
149 virtual void setName(
const std::string &name);
150 virtual std::string getName()
const;
153 virtual DataSet & getNonConstAttributes();
154 Graph* graph_component;
157 virtual node restoreNode(node);
158 virtual edge restoreEdge(edge, node source, node target);
159 virtual void restoreNodes(
const std::vector<node>&);
160 virtual void restoreEdges(
const std::vector<edge>& edges,
161 const std::vector<std::pair<node, node> >& ends);
164 virtual void removeNode(
const node);
165 virtual void removeEdge(
const edge);
167 virtual void removeSubGraph(Graph*);
168 virtual void clearSubGraphs();
169 virtual void restoreSubGraph(Graph*);
170 virtual void setSubGraphToKeep(Graph*);
172 virtual bool renameLocalProperty(PropertyInterface* prop,
173 const std::string& newName);
177 template<
typename PropertyType>
178 PropertyType* GraphDecorator::getProperty(
const std::string &name) {
179 if (graph_component->existProperty(name)) {
181 assert (dynamic_cast<PropertyType *>(prop)!=NULL);
182 return dynamic_cast<PropertyType *
>(prop);
185 return graph_component->getLocalProperty<PropertyType>(name);
193 #endif //DOXYGEN_NOTFOR_DEVEL
PropertyInterface describes the interface of a graph property.
The edge struct represents an edge in a Graph object.
The node struct represents a node in a Graph object.