21 #ifndef Tulip_SUPERGRAPHIMPL_H 22 #define Tulip_SUPERGRAPHIMPL_H 28 #include <tulip/GraphAbstract.h> 29 #include <tulip/GraphStorage.h> 30 #include <tulip/IdManager.h> 33 template <
class itType>
36 class GraphUpdatesRecorder;
39 class TLP_SCOPE GraphImpl :
public GraphAbstract {
41 friend class GraphUpdatesRecorder;
42 friend class TLPExport;
46 ~GraphImpl()
override;
47 void clear()
override;
49 inline bool isElement(
const node n)
const override {
50 return storage.isElement(n);
52 bool isElement(
const edge e)
const override {
53 return storage.isElement(e);
55 edge existEdge(
const node source,
const node target,
bool directed =
true)
const override;
56 node addNode()
override;
57 void addNodes(
unsigned int nb)
override;
58 void addNodes(
unsigned int nb, std::vector<node> &addedNodes)
override;
59 void addNode(
const node)
override;
60 void addNodes(Iterator<node> *nodes)
override;
61 edge addEdge(
const node,
const node)
override;
62 void addEdges(
const std::vector<std::pair<node, node>> &edges)
override;
63 void addEdges(
const std::vector<std::pair<node, node>> &edges,
64 std::vector<edge> &addedEdges)
override;
65 void addEdge(
const edge)
override;
66 void addEdges(Iterator<edge> *edges)
override;
67 void delNode(
const tlp::node n,
bool deleteInAllGraphs =
false)
override;
68 void delEdge(
const tlp::edge e,
bool deleteInAllGraphs =
false)
override;
69 inline void setEdgeOrder(
const node n,
const std::vector<edge> &v)
override {
70 storage.setEdgeOrder(n, v);
72 inline void swapEdgeOrder(
const node n,
const edge e1,
const edge e2)
override {
73 storage.swapEdgeOrder(n, e1, e2);
76 inline const std::vector<node> &nodes()
const override {
77 return storage.nodes();
79 inline unsigned int nodePos(
const node n)
const override {
80 return storage.nodePos(n);
82 Iterator<node> *getNodes()
const override;
83 Iterator<node> *getInNodes(
const node)
const override;
84 Iterator<node> *getOutNodes(
const node)
const override;
85 Iterator<node> *getInOutNodes(
const node)
const override;
86 inline const std::vector<edge> &edges()
const override {
87 return storage.edges();
89 inline unsigned int edgePos(
const edge e)
const override {
90 return storage.edgePos(e);
92 Iterator<edge> *getEdges()
const override;
93 Iterator<edge> *getInEdges(
const node)
const override;
94 Iterator<edge> *getOutEdges(
const node)
const override;
95 Iterator<edge> *getInOutEdges(
const node)
const override;
96 std::vector<edge> getEdges(
const node source,
const node target,
97 bool directed =
true)
const override;
98 bool getEdges(
const node source,
const node target,
bool directed, std::vector<edge> &edges,
99 const Graph *sg =
nullptr,
bool onlyFirst =
false)
const {
100 return storage.getEdges(source, target, directed, edges, sg, onlyFirst);
102 inline const std::vector<edge> &allEdges(
const node n)
const override {
103 return storage.adj(n);
106 inline unsigned int deg(
const node n)
const override {
107 assert(isElement(n));
108 return storage.deg(n);
110 inline unsigned int indeg(
const node n)
const override {
111 assert(isElement(n));
112 return storage.indeg(n);
114 inline unsigned int outdeg(
const node n)
const override {
115 assert(isElement(n));
116 return storage.outdeg(n);
119 inline node source(
const edge e)
const override {
120 assert(isElement(e));
121 return storage.source(e);
123 inline node target(
const edge e)
const override {
124 assert(isElement(e));
125 return storage.target(e);
127 inline node opposite(
const edge e,
const node n)
const override {
128 assert(isElement(e));
129 return storage.opposite(e, n);
131 inline const std::pair<node, node> &ends(
const edge e)
const override {
132 return storage.ends(e);
134 inline void setSource(
const edge e,
const node newSrc)
override {
135 assert(isElement(e));
136 this->setEnds(e, newSrc, node());
138 inline void setTarget(
const edge e,
const node newTgt)
override {
139 assert(isElement(e));
140 this->setEnds(e, node(), newTgt);
142 void setEnds(
const edge,
const node,
const node)
override;
143 void reverse(
const edge)
override;
145 inline unsigned int numberOfEdges()
const override {
146 return storage.numberOfEdges();
148 inline unsigned int numberOfNodes()
const override {
149 return storage.numberOfNodes();
151 inline void sortElts()
override {
156 void push(
bool unpopAllowed =
true,
157 std::vector<PropertyInterface *> *propertiesToPreserveOnPop =
nullptr)
override;
158 void pop(
bool unpopAllowed =
true)
override;
159 void popIfNoUpdates()
override;
160 void unpop()
override;
161 bool canPop()
override;
162 bool canUnpop()
override;
163 bool canPopThenUnpop()
override;
166 void treatEvents(
const std::vector<Event> &)
override;
169 unsigned int getSubGraphId(
unsigned int id);
170 void freeSubGraphId(
unsigned int id);
174 void reserveNodes(
unsigned int nbNodes)
override;
175 void reserveEdges(
unsigned int nbEdges)
override;
180 void restoreNode(node)
override;
181 void restoreEdge(edge, node source, node target)
override;
184 void removeNode(
const node)
override;
185 void removeEdge(
const edge)
override;
187 bool canDeleteProperty(Graph *g, PropertyInterface *prop)
override;
190 GraphStorage storage;
192 std::list<GraphUpdatesRecorder *> previousRecorders;
193 std::list<Graph *> observedGraphs;
194 std::list<PropertyInterface *> observedProps;
195 std::list<GraphUpdatesRecorder *> recorders;
197 void observeUpdates(Graph *);
198 void unobserveUpdates();
199 void delPreviousRecorders();
The edge struct represents an edge in a Graph object.
The node struct represents a node in a Graph object.