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;
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::vector<node> &nodes,
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);
100 virtual void addNodes(
unsigned int nb, std::vector<node>& addedNodes);
101 virtual void addNode(
const node);
103 virtual edge addEdge(
const node n1,
const node n2);
104 virtual void addEdges(
const std::vector<std::pair<node, node> >& edges);
105 virtual void addEdges(
const std::vector<std::pair<node, node> >& edges,
106 std::vector<edge>& addedEdges);
107 virtual void addEdge(
const edge);
109 virtual void delNode(
const tlp::node n,
bool deleteInAllGraphs =
false);
110 virtual void delNodes(
Iterator<node>* itN,
bool deleteInAllGraphs);
111 virtual void delEdge(
const tlp::edge e,
bool deleteInAllGraphs =
false);
112 virtual void delEdges(
Iterator<edge>* itE,
bool deleteInAllGraphs =
false);
113 virtual void setEdgeOrder(
const node n,
const std::vector<edge> & s);
114 virtual void swapEdgeOrder(
const node n ,
const edge e1,
const edge e2);
116 virtual const std::vector<node>& nodes()
const;
117 virtual unsigned int nodePos(
const node)
const;
124 virtual const std::vector<edge>& edges()
const;
125 virtual unsigned int edgePos(
const edge)
const;
130 virtual const std::vector<edge>& allEdges(
const node n)
const;
132 virtual void sortElts();
134 template<
typename PropertyType>
135 PropertyType* getProperty(
const std::string &name);
136 virtual PropertyInterface* getProperty(
const std::string &name)
const;
137 virtual bool existProperty(
const std::string&name)
const;
138 virtual bool existLocalProperty(
const std::string&name)
const;
139 virtual void delLocalProperty(
const std::string&name);
140 virtual void addLocalProperty(
const std::string &name, PropertyInterface *prop);
148 virtual void push(
bool unpopAllowed =
true,
149 std::vector<PropertyInterface*>* propertiesToPreserveOnPop= NULL);
150 virtual void pop(
bool unpopAllowed =
true);
151 virtual void popIfNoUpdates();
152 virtual void unpop();
153 virtual bool canPop();
154 virtual bool canUnpop();
155 virtual bool canPopThenUnpop();
158 virtual void setName(
const std::string &name);
159 virtual std::string getName()
const;
162 virtual DataSet & getNonConstAttributes();
163 Graph* graph_component;
166 virtual void restoreNode(node);
167 virtual void restoreEdge(edge, node source, node target);
170 virtual void removeNode(
const node);
171 virtual void removeEdge(
const edge);
173 virtual void removeSubGraph(Graph*);
174 virtual void clearSubGraphs();
175 virtual void restoreSubGraph(Graph*);
176 virtual void setSubGraphToKeep(Graph*);
178 virtual bool renameLocalProperty(PropertyInterface* prop,
179 const std::string& newName);
183 template<
typename PropertyType>
184 PropertyType* GraphDecorator::getProperty(
const std::string &name) {
185 if (graph_component->existProperty(name)) {
187 assert (dynamic_cast<PropertyType *>(prop)!=NULL);
188 return dynamic_cast<PropertyType *
>(prop);
191 return graph_component->getLocalProperty<PropertyType>(name);
199 #endif //DOXYGEN_NOTFOR_DEVEL
PropertyInterface describes the interface of a graph property.
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.