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;
49 bool isElement(
const node )
const;
50 bool isElement(
const edge )
const;
51 edge existEdge(
const node source,
const node target,
52 bool directed =
true)
const;
54 void addNodes(
unsigned int nb);
55 void addNodes(
unsigned int nb, std::vector<node>& addedNodes);
56 void addNode(
const node);
58 edge addEdge(
const node ,
const node);
59 void addEdges(
const std::vector<std::pair<node, node> >& edges);
60 void addEdges(
const std::vector<std::pair<node, node> >& edges,
61 std::vector<edge>& addedEdges);
62 void addEdge(
const edge);
64 void delNode(
const tlp::node n,
bool deleteInAllGraphs =
false);
65 void delEdge(
const tlp::edge e,
bool deleteInAllGraphs =
false);
66 void setEdgeOrder(
const node,
const std::vector<edge> & );
67 void swapEdgeOrder(
const node,
const edge ,
const edge );
77 std::vector<edge> getEdges(
const node source,
const node target,
78 bool directed =
true)
const;
79 bool getEdges(
const node source,
const node target,
bool directed,
80 std::vector<edge>& edges)
const {
81 return storage.getEdges(source, target, directed, edges);
84 void getInOutEdges(
const node, std::vector<edge>& edges,
85 bool loopsOnlyOnce =
false)
const;
87 unsigned int deg(
const node )
const;
88 unsigned int indeg(
const node)
const;
89 unsigned int outdeg(
const node)
const;
91 virtual node source(
const edge)
const;
92 virtual node target(
const edge)
const;
93 virtual node opposite(
const edge,
const node n)
const;
94 virtual const std::pair<node, node>& ends(
const edge e)
const;
95 virtual void setEnds(
const edge,
const node,
const node);
96 virtual void reverse(
const edge);
98 unsigned int numberOfEdges()
const;
99 unsigned int numberOfNodes()
const;
102 virtual void push(
bool unpopAllowed =
true,
103 std::vector<PropertyInterface*>* propertiesToPreserveOnPop= NULL);
104 virtual void pop(
bool unpopAllowed =
true);
105 virtual void unpop();
106 virtual bool canPop();
107 virtual bool canUnpop();
108 virtual bool canPopThenUnpop();
111 void treatEvents(
const std::vector<Event> &);
114 unsigned int getSubGraphId(
unsigned int id);
115 void freeSubGraphId(
unsigned int id);
119 virtual void reserveNodes(
unsigned int nbNodes);
120 virtual void reserveEdges(
unsigned int nbEdges);
125 virtual node restoreNode(node);
126 virtual void restoreNodes(
const std::vector<node>&);
127 virtual edge restoreEdge(edge, node source, node target);
128 virtual void restoreEdges(
const std::vector<edge>& edges,
129 const std::vector<std::pair<node, node> >& ends);
132 virtual void removeNode(
const node);
133 virtual void removeEdge(
const edge);
135 virtual bool canDeleteProperty(Graph* g, PropertyInterface *prop);
138 GraphStorage storage;
140 std::list<GraphUpdatesRecorder*> previousRecorders;
141 std::list<Graph *> observedGraphs;
142 std::list<PropertyInterface*> observedProps;
143 std::list<GraphUpdatesRecorder*> recorders;
145 void restoreAdj(node, std::vector<edge>&);
146 void observeUpdates(Graph*);
147 void unobserveUpdates();
148 void delPreviousRecorders();
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.