Tulip  4.4.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
GraphDecorator.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef DOXYGEN_NOTFOR_DEVEL
22 
23 #ifndef Tulip_GraphDecorator_H
24 #define Tulip_GraphDecorator_H
25 
26 #include <tulip/Graph.h>
27 
28 namespace tlp {
29 
30 class TLP_SCOPE GraphDecorator : public Graph { // non-orienté, planaire
31 public:
32  GraphDecorator(Graph* s) {
33  assert(s);
34  graph_component = s;
35  }
36  virtual ~GraphDecorator() {
37  notifyDestroy();
38  }
39 
40  virtual void clear();
41  virtual Graph *addSubGraph(BooleanProperty *selection=0,
42  std::string name = "unnamed");
43  virtual void delSubGraph(Graph * s);
44  virtual void delAllSubGraphs(Graph *s);
45  virtual Graph* getSuperGraph()const;
46  virtual void setSuperGraph(Graph* s);
47  virtual Graph* getRoot() const;
48  virtual Iterator<Graph *> * getSubGraphs() const;
49  virtual bool isSubGraph(const Graph* sg) const;
50  virtual bool isDescendantGraph(const Graph* sg) const;
51  virtual Graph* getSubGraph(unsigned int id) const;
52  virtual Graph* getSubGraph(const std::string &name) const;
53  virtual Graph* getDescendantGraph(unsigned int id) const;
54  virtual Graph* getDescendantGraph(const std::string &name) const;
55  virtual unsigned int numberOfSubGraphs() const;
56  virtual unsigned int numberOfDescendantGraphs() const;
57 
58  //============================================================
59  virtual node source(const edge e)const;
60  virtual void setSource(const edge, const node);
61  virtual node target(const edge e)const;
62  virtual void setTarget(const edge, const node);
63  virtual node opposite(const edge e, const node n)const;
64  virtual edge existEdge(const node n, const node m, bool directed = true)const;
65  virtual bool hasEdge(const node source, const node target,
66  bool directed = true) const;
67  virtual std::vector<edge> getEdges(const node source, const node target,
68  bool directed = true) const;
69  virtual const std::pair<node, node>& ends(const edge e) const;
70  virtual void setEnds(const edge, const node, const node);
71  virtual void reverse(const edge e);
72  virtual unsigned int deg(const node n)const;
73  virtual unsigned int indeg(const node n)const;
74  virtual unsigned int outdeg(const node n)const;
75  virtual Graph* getNodeMetaInfo(const node n)const;
76 
77  //============================================================
78  virtual node getOneNode() const;
79  virtual node getInNode(const node n,unsigned int i)const;
80  virtual node getOutNode(const node n,unsigned int i) const;
81  virtual edge getOneEdge() const;
82 
83  virtual unsigned int numberOfNodes()const;
84  virtual unsigned int numberOfEdges()const;
85 
86  //=========================================================================
87 
88  virtual void reserveNodes(unsigned int nbNodes);
89  virtual void reserveEdges(unsigned int nbEdges);
90 
91  //============================================================
92  virtual bool isElement(const node n) const;
93  virtual bool isMetaNode(const node n) const;
94  virtual bool isElement(const edge e) const;
95  virtual bool isMetaEdge(const edge e) const;
96  virtual node addNode();
97  virtual void addNodes(unsigned int nb, std::vector<node>& addedNodes);
98  virtual void addNode(const node);
99  virtual void addNodes(Iterator<node>* nodes);
100  virtual edge addEdge(const node n1, const node n2);
101  virtual void addEdges(const std::vector<std::pair<node, node> >& edges,
102  std::vector<edge>& addedEdges);
103  virtual void addEdge(const edge);
104  virtual void addEdges(Iterator<edge>* edges);
105  virtual void delNode(const tlp::node n, bool deleteInAllGraphs = false);
106  virtual void delNodes(Iterator<node>* itN, bool deleteInAllGraphs);
107  virtual void delEdge(const tlp::edge e, bool deleteInAllGraphs = false);
108  virtual void delEdges(Iterator<edge>* itE, bool deleteInAllGraphs = false);
109  virtual void setEdgeOrder(const node n,const std::vector<edge> & s);
110  virtual void swapEdgeOrder(const node n ,const edge e1, const edge e2);
111 
112  virtual Iterator<node>* getNodes() const;
113  virtual Iterator<node>* getInNodes(const node n) const;
114  virtual Iterator<node>* getOutNodes(const node n) const;
115  virtual Iterator<node>* getInOutNodes(const node n) const;
116  virtual Iterator<node>* bfs(const node root = node()) const;
117  virtual Iterator<node>* dfs(const node root = node()) const;
118  virtual Iterator<edge>* getEdges() const;
119  virtual Iterator<edge>* getOutEdges(const node n) const;
120  virtual Iterator<edge>* getInOutEdges(const node n) const;
121  virtual Iterator<edge>* getInEdges(const node n) const;
122  virtual Iterator<edge>* getEdgeMetaInfo(const edge) const;
123  //============================================================
124  virtual PropertyInterface* getProperty(const std::string &name) const;
125  virtual bool existProperty(const std::string&name) const;
126  virtual bool existLocalProperty(const std::string&name) const;
127  virtual void delLocalProperty(const std::string&name);
128  virtual void addLocalProperty(const std::string &name, PropertyInterface *prop);
129  virtual Iterator<std::string>* getLocalProperties() const;
130  virtual Iterator<std::string>* getInheritedProperties() const;
131  virtual Iterator<std::string>* getProperties() const;
132  virtual Iterator<PropertyInterface*>* getLocalObjectProperties() const;
133  virtual Iterator<PropertyInterface*>* getInheritedObjectProperties() const;
134  virtual Iterator<PropertyInterface*>* getObjectProperties() const;
135  // updates management
136  virtual void push(bool unpopAllowed = true,
137  std::vector<PropertyInterface*>* propertiesToPreserveOnPop= NULL);
138  virtual void pop(bool unpopAllowed = true);
139  virtual void unpop();
140  virtual bool canPop();
141  virtual bool canUnpop();
142  virtual bool canPopThenUnpop();
143  //============================================================
144 
145  virtual void setName(const std::string &name);
146  virtual std::string getName() const;
147 
148 protected:
149  virtual DataSet & getNonConstAttributes();
150  Graph* graph_component;
151  // designed to reassign an id to a previously deleted elt
152  // called by GraphUpdatesRecorder
153  virtual node restoreNode(node);
154  virtual edge restoreEdge(edge, node source, node target);
155  virtual void restoreNodes(const std::vector<node>&);
156  virtual void restoreEdges(const std::vector<edge>& edges,
157  const std::vector<std::pair<node, node> >& ends);
158  // designed to only update own structures
159  // used by GraphUpdatesRecorder
160  virtual void removeNode(const node);
161  virtual void removeEdge(const edge);
162  // internally used to deal with sub graph deletion
163  virtual void removeSubGraph(Graph*);
164  virtual void clearSubGraphs();
165  virtual void restoreSubGraph(Graph*);
166  virtual void setSubGraphToKeep(Graph*);
167  // internally used for property renaming
168  virtual bool renameLocalProperty(PropertyInterface* prop,
169  const std::string& newName);
170 };
171 
172 }
173 
174 #endif
175 
176 #endif //DOXYGEN_NOTFOR_DEVEL
177 ///@endcond