graph  5.0.5
Graph: generic attributed relational graphs
edge.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 #ifndef GRAPH_GRAPH_EDGE_H
35 #define GRAPH_GRAPH_EDGE_H
36 
37 
38 //=============================================================================
39 // H E A D E R F I L E S
40 //=============================================================================
41 
43 #ifndef GRAPH_GRAPH_GRAPHOBJECT_H
45 #endif
47 
48 
49 //=============================================================================
50 // F O R W A R D D E C L A R A T I O N S
51 //=============================================================================
52 
53 class Vertex;
54 
55 
56 //=============================================================================
57 // C L A S S D E C L A R A T I O N
58 //=============================================================================
59 
68 class GRAPH_API Edge : public GraphObject
69 {
70 
71 private:
72 
73  //---------------------------------------------------------------------
75  //---------------------------------------------------------------------
77 
80 
82 
83 public:
84 
85  //---------------------------------------------------------------------
87  //---------------------------------------------------------------------
89 
106 
108 
109  //---------------------------------------------------------------------
111  //---------------------------------------------------------------------
113 
116  virtual ~Edge();
117 
119 
120  //---------------------------------------------------------------------
122  //---------------------------------------------------------------------
124 
127  virtual bool isDirected() const = 0;
128 
131  virtual bool isUndirected() const = 0;
132 
134 
135  //---------------------------------------------------------------------
137  //---------------------------------------------------------------------
139 
144  bool hasVertex(const Vertex* vertex) const;
146  size_t verticesSize() const;
147 
149 
150  //---------------------------------------------------------------------
152  //---------------------------------------------------------------------
154 
159  iterator begin();
160 
165  iterator end();
166 
171  const_iterator begin() const;
172 
177  const_iterator end() const;
178 
184  reverse_iterator rbegin();
185 
191  reverse_iterator rend();
192 
198  const_reverse_iterator rbegin() const;
199 
205  const_reverse_iterator rend() const;
206 
208 
209 protected:
210 
211  //---------------------------------------------------------------------
213  //---------------------------------------------------------------------
215 
220  Edge(std::string s);
221 
226  Edge(const Edge& x);
227 
232  virtual Edge* cloneEdge() const = 0;
233 
235 
236 private:
237 
239  friend class Graph;
240 
241  //---------------------------------------------------------------------
243  //---------------------------------------------------------------------
245 
251  void addVertices(Vertex* vertex1, Vertex* vertex2);
252 
257  void removeVertex(Vertex* vertex);
258 
260 
261  //---------------------------------------------------------------------
263  //---------------------------------------------------------------------
265 
268  Edge& operator=(const Edge&);
269 
271 
272  //---------------------------------------------------------------------
274  //---------------------------------------------------------------------
276 
281  VSet _vertices;
282 
284 };
285 
286 
287 //=============================================================================
288 // I N L I N E M E T H O D S
289 //=============================================================================
290 
291 inline
292 bool
293 Edge::hasVertex(const Vertex* vertex) const
294 {
295  return _vertices[0] == vertex || _vertices[1] == vertex;
296 }
297 
298 
299 inline
302 {
303  return _vertices.begin();
304 }
305 
306 
307 inline
310 {
311  return _vertices.end();
312 }
313 
314 
315 inline
317 Edge::begin() const
318 {
319  return _vertices.begin();
320 }
321 
322 
323 inline
325 Edge::end() const
326 {
327  return _vertices.end();
328 }
329 
330 
331 inline
334 {
335  return _vertices.rbegin();
336 }
337 
338 
339 inline
342 {
343  return _vertices.rend();
344 }
345 
346 
347 inline
350 {
351  return _vertices.rbegin();
352 }
353 
354 
355 inline
357 Edge::rend() const
358 {
359  return _vertices.rend();
360 }
361 
362 
363 namespace carto
364 {
366 }
367 
368 
369 #endif
#define DECLARE_GENERIC_OBJECT_TYPE(T)
std::reverse_iterator< iterator > reverse_iterator
reverse_iterator rbegin()
Get the beginning of the reversed vertex collection of the graph.
Definition: edge.h:333
iterator end()
Get the end of the edge collection.
Definition: vertex.h:301
void removeVertex(Vertex *vertex)
Delete and remove a vertex from the graph.
The base class for graphs.
Definition: graph.h:71
iterator begin()
Get the beginning of the edge collection.
Definition: vertex.h:293
VSet::pointer pointer
Definition: edge.h:93
The abstract base class for all types of edges; edges are created and managed by Graphs.
Definition: edge.h:68
VSet::const_iterator const_iterator
Definition: edge.h:101
#define GRAPH_API
Definition: graph_config.h:46
VSet::const_reference const_reference
Definition: edge.h:97
VSet::const_reverse_iterator const_reverse_iterator
Definition: edge.h:105
iterator end()
Get the end of the vertex collection of the graph.
Definition: edge.h:309
VSet::reverse_iterator reverse_iterator
Definition: edge.h:103
bool hasVertex(const Vertex *vertex) const
Does this edge contain a given vertex?
Definition: edge.h:293
VSet::value_type value_type
Definition: edge.h:91
reverse_iterator rend()
Get the end of the reversed vertex collection of the graph.
Definition: edge.h:341
VSet::reference reference
Definition: edge.h:95
std::reverse_iterator< const_iterator > const_reverse_iterator
VSet::iterator iterator
Definition: edge.h:99
The abstract base class for graphs, vertices and edges.
Definition: graphobject.h:52
iterator begin()
Get the beginning of the vertex collection of the graph.
Definition: edge.h:301
Vertices are created and managed by Graphs.
Definition: vertex.h:63