graph  5.1.2
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  // from GenericObject
210  virtual std::string type() const CARTO_OVERRIDE
211  { return "Edge"; }
212 
213 protected:
214 
215  //---------------------------------------------------------------------
217  //---------------------------------------------------------------------
219 
224  Edge(std::string s);
225 
230  Edge(const Edge& x);
231 
236  virtual Edge* cloneEdge() const = 0;
237 
239 
240 private:
241 
243  friend class Graph;
244 
245  //---------------------------------------------------------------------
247  //---------------------------------------------------------------------
249 
255  void addVertices(Vertex* vertex1, Vertex* vertex2);
256 
261  void removeVertex(Vertex* vertex);
262 
264 
265  //---------------------------------------------------------------------
267  //---------------------------------------------------------------------
269 
272  Edge& operator=(const Edge&);
273 
275 
276  //---------------------------------------------------------------------
278  //---------------------------------------------------------------------
280 
285  VSet _vertices;
286 
288 };
289 
290 
291 namespace carto
292 {
293 
294  template <> inline std::string DataTypeCode<Edge>::objectType()
295  { return "Edge"; }
296  template <> inline std::string DataTypeCode<Edge>::dataType()
297  { return "VOID"; }
298  template <> inline std::string DataTypeCode<Edge>::name()
299  { return "Edge"; }
300 
301 }
302 
303 
304 //=============================================================================
305 // I N L I N E M E T H O D S
306 //=============================================================================
307 
308 inline
309 bool
310 Edge::hasVertex(const Vertex* vertex) const
311 {
312  return _vertices[0] == vertex || _vertices[1] == vertex;
313 }
314 
315 
316 inline
319 {
320  return _vertices.begin();
321 }
322 
323 
324 inline
327 {
328  return _vertices.end();
329 }
330 
331 
332 inline
334 Edge::begin() const
335 {
336  return _vertices.begin();
337 }
338 
339 
340 inline
342 Edge::end() const
343 {
344  return _vertices.end();
345 }
346 
347 
348 inline
351 {
352  return _vertices.rbegin();
353 }
354 
355 
356 inline
359 {
360  return _vertices.rend();
361 }
362 
363 
364 inline
367 {
368  return _vertices.rbegin();
369 }
370 
371 
372 inline
374 Edge::rend() const
375 {
376  return _vertices.rend();
377 }
378 
379 
380 namespace carto
381 {
383 }
384 
385 
386 #endif
The abstract base class for all types of edges; edges are created and managed by Graphs.
Definition: edge.h:69
VSet::iterator iterator
Definition: edge.h:99
iterator begin()
Get the beginning of the vertex collection of the graph.
Definition: edge.h:318
VSet::reverse_iterator reverse_iterator
Definition: edge.h:103
virtual bool isDirected() const =0
Is this edge directed?
virtual Edge * cloneEdge() const =0
The programmer should not clone.
Edge(const Edge &x)
The programmer should not call the copy constructor.
iterator end()
Get the end of the vertex collection of the graph.
Definition: edge.h:326
VSet::const_iterator const_iterator
Definition: edge.h:101
Edge(std::string s)
The programmer should not call the constructor.
size_t verticesSize() const
number of vertices
reverse_iterator rend()
Get the end of the reversed vertex collection of the graph.
Definition: edge.h:358
VSet::reference reference
Definition: edge.h:95
virtual ~Edge()
virtual bool isUndirected() const =0
Is this edge undirected?
reverse_iterator rbegin()
Get the beginning of the reversed vertex collection of the graph.
Definition: edge.h:350
virtual std::string type() const CARTO_OVERRIDE
Definition: edge.h:210
VSet::value_type value_type
Definition: edge.h:91
bool hasVertex(const Vertex *vertex) const
Does this edge contain a given vertex?
Definition: edge.h:310
VSet::const_reference const_reference
Definition: edge.h:97
VSet::const_reverse_iterator const_reverse_iterator
Definition: edge.h:105
VSet::pointer pointer
Definition: edge.h:93
The abstract base class for graphs, vertices and edges.
Definition: graphobject.h:53
The base class for graphs.
Definition: graph.h:72
void removeVertex(Vertex *vertex)
Delete and remove a vertex from the graph.
Vertices are created and managed by Graphs.
Definition: vertex.h:64
std::string name()
std::string objectType()
std::string dataType()
#define GRAPH_API
Definition: graph_config.h:46
#define DECLARE_GENERIC_OBJECT_TYPE(T)
reverse_iterator rbegin()
iterator end()
iterator begin()
std::reverse_iterator< const_iterator > const_reverse_iterator
reverse_iterator rend()
const value_type & const_reference
std::reverse_iterator< iterator > reverse_iterator