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;
53 edge existEdge(
const node source,
const node target,
54 bool directed =
true)
const;
56 void addNodes(
unsigned int nb);
57 void addNodes(
unsigned int nb, std::vector<node>& addedNodes);
58 void addNode(
const node);
59 void addNodes(Iterator<node>* nodes);
60 edge addEdge(
const node ,
const node);
61 void addEdges(
const std::vector<std::pair<node, node> >& edges);
62 void addEdges(
const std::vector<std::pair<node, node> >& edges,
63 std::vector<edge>& addedEdges);
64 void addEdge(
const edge);
65 void addEdges(Iterator<edge>* edges);
66 void delNode(
const tlp::node n,
bool deleteInAllGraphs =
false);
67 void delEdge(
const tlp::edge e,
bool deleteInAllGraphs =
false);
68 void setEdgeOrder(
const node,
const std::vector<edge> & );
69 void swapEdgeOrder(
const node,
const edge ,
const edge );
71 Iterator<node>* getNodes()
const;
72 Iterator<node>* getInNodes(
const node )
const;
73 Iterator<node>* getOutNodes(
const node )
const;
74 Iterator<node>* getInOutNodes(
const node )
const;
75 Iterator<edge>* getEdges()
const;
76 Iterator<edge>* getInEdges(
const node )
const;
77 Iterator<edge>* getOutEdges(
const node )
const;
78 Iterator<edge>* getInOutEdges(
const node )
const;
79 std::vector<edge> getEdges(
const node source,
const node target,
80 bool directed =
true)
const;
81 bool getEdges(
const node source,
const node target,
bool directed,
82 std::vector<edge>& edges)
const {
83 return storage.getEdges(source, target, directed, edges);
86 void getInOutEdges(
const node, std::vector<edge>& edges,
87 bool loopsOnlyOnce =
false)
const;
89 unsigned int deg(
const node )
const;
90 unsigned int indeg(
const node)
const;
91 unsigned int outdeg(
const node)
const;
93 virtual node source(
const edge)
const;
94 virtual node target(
const edge)
const;
95 virtual node opposite(
const edge,
const node n)
const;
96 virtual const std::pair<node, node>& ends(
const edge e)
const;
97 virtual void setEnds(
const edge,
const node,
const node);
98 virtual void reverse(
const edge);
100 unsigned int numberOfEdges()
const;
101 unsigned int numberOfNodes()
const;
104 virtual void push(
bool unpopAllowed =
true,
105 std::vector<PropertyInterface*>* propertiesToPreserveOnPop= NULL);
106 virtual void pop(
bool unpopAllowed =
true);
107 virtual void unpop();
108 virtual bool canPop();
109 virtual bool canUnpop();
110 virtual bool canPopThenUnpop();
113 void treatEvents(
const std::vector<Event> &);
116 unsigned int getSubGraphId(
unsigned int id);
117 void freeSubGraphId(
unsigned int id);
121 virtual void reserveNodes(
unsigned int nbNodes);
122 virtual void reserveEdges(
unsigned int nbEdges);
127 virtual node restoreNode(node);
128 virtual void restoreNodes(
const std::vector<node>&);
129 virtual edge restoreEdge(edge, node source, node target);
130 virtual void restoreEdges(
const std::vector<edge>& edges,
131 const std::vector<std::pair<node, node> >& ends);
134 virtual void removeNode(
const node);
135 virtual void removeEdge(
const edge);
137 virtual bool canDeleteProperty(Graph* g, PropertyInterface *prop);
140 GraphStorage storage;
142 std::list<GraphUpdatesRecorder*> previousRecorders;
143 std::list<Graph *> observedGraphs;
144 std::list<PropertyInterface*> observedProps;
145 std::list<GraphUpdatesRecorder*> recorders;
147 void restoreAdj(node, std::vector<edge>&);
148 void observeUpdates(Graph*);
149 void unobserveUpdates();
150 void delPreviousRecorders();
The edge struct represents an edge in a Graph object.
The node struct represents a node in a Graph object.