21 #ifndef Tulip_SUPERGRAPHIMPL_H
22 #define Tulip_SUPERGRAPHIMPL_H
24 #ifndef DOXYGEN_NOTFOR_USER
30 #include <tulip/GraphAbstract.h>
31 #include <tulip/GraphStorage.h>
32 #include <tulip/IdManager.h>
35 template<
class itType >
38 class GraphUpdatesRecorder;
41 class TLP_SCOPE GraphImpl:
public GraphAbstract {
43 friend class GraphUpdatesRecorder;
44 friend class TLPExport;
51 bool isElement(
const node )
const;
52 bool isElement(
const edge )
const;
54 void addNodes(
unsigned int nb, std::vector<node>& addedNodes);
55 void addNode(
const node);
56 void addNodes(Iterator<node>* nodes);
57 edge addEdge(
const node ,
const node);
58 void addEdges(
const std::vector<std::pair<node, node> >& edges,
59 std::vector<edge>& addedEdges);
60 void addEdge(
const edge);
61 void addEdges(Iterator<edge>* edges);
62 void delNode(
const tlp::node n,
bool deleteInAllGraphs =
false);
63 void delEdge(
const tlp::edge e,
bool deleteInAllGraphs =
false);
64 void setEdgeOrder(
const node,
const std::vector<edge> & );
65 void swapEdgeOrder(
const node,
const edge ,
const edge );
67 Iterator<node>* getNodes()
const;
68 Iterator<node>* getInNodes(
const node )
const;
69 Iterator<node>* getOutNodes(
const node )
const;
70 Iterator<node>* getInOutNodes(
const node )
const;
71 Iterator<edge>* getEdges()
const;
72 Iterator<edge>* getInEdges(
const node )
const;
73 Iterator<edge>* getOutEdges(
const node )
const;
74 Iterator<edge>* getInOutEdges(
const node )
const;
76 void getInOutEdges(
const node, std::vector<edge>& edges,
77 bool loopsOnlyOnce =
false)
const;
79 unsigned int deg(
const node )
const;
80 unsigned int indeg(
const node)
const;
81 unsigned int outdeg(
const node)
const;
83 virtual node source(
const edge)
const;
84 virtual node target(
const edge)
const;
85 virtual node opposite(
const edge,
const node n)
const;
86 virtual const std::pair<node, node>& ends(
const edge e)
const;
87 virtual void setEnds(
const edge,
const node,
const node);
88 virtual void reverse(
const edge);
90 unsigned int numberOfEdges()
const;
91 unsigned int numberOfNodes()
const;
94 virtual void push(
bool unpopAllowed =
true,
95 std::vector<PropertyInterface*>* propertiesToPreserveOnPop= NULL);
96 virtual void pop(
bool unpopAllowed =
true);
98 virtual bool canPop();
99 virtual bool canUnpop();
100 virtual bool canPopThenUnpop();
103 void treatEvents(
const std::vector<Event> &);
104 void observableDestroyed(Observable*);
107 unsigned int getSubGraphId(
unsigned int id);
108 void freeSubGraphId(
unsigned int id);
112 virtual void reserveNodes(
unsigned int nbNodes);
113 virtual void reserveEdges(
unsigned int nbEdges);
118 virtual node restoreNode(node);
119 virtual void restoreNodes(
const std::vector<node>&);
120 virtual edge restoreEdge(edge, node source, node target);
121 virtual void restoreEdges(
const std::vector<edge>& edges,
122 const std::vector<std::pair<node, node> >& ends);
125 virtual void removeNode(
const node);
126 virtual void removeEdge(
const edge);
128 virtual bool canDeleteProperty(Graph* g, PropertyInterface *prop);
131 GraphStorage storage;
133 std::list<GraphUpdatesRecorder*> previousRecorders;
134 std::list<Graph *> observedGraphs;
135 std::list<PropertyInterface*> observedProps;
136 std::list<GraphUpdatesRecorder*> recorders;
138 void restoreAdj(node, std::vector<edge>&);
139 void observeUpdates(Graph*);
140 void unobserveUpdates();
141 void delPreviousRecorders();