graph  5.0.5
Graph: generic attributed relational graphs
vertex.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_VERTEX_H
35 #define GRAPH_GRAPH_VERTEX_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
46 #include <set>
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 Edge;
54 
55 
56 //=============================================================================
57 // C L A S S D E C L A R A T I O N
58 //=============================================================================
59 
64 {
65 
66 private:
67  typedef std::set<Edge*> ESet;
68 
69 
70 public:
71  typedef ESet::value_type value_type;
72 #ifndef _WIN32
73  typedef ESet::pointer pointer;
75 #endif
76  typedef ESet::reference reference;
77  typedef ESet::const_reference const_reference;
78  typedef ESet::iterator iterator;
79  typedef ESet::const_iterator const_iterator;
80  typedef ESet::reverse_iterator reverse_iterator;
81  typedef ESet::const_reverse_iterator const_reverse_iterator;
82 
83  //---------------------------------------------------------------------
85  //---------------------------------------------------------------------
87 
88  virtual ~Vertex();
89 
91 
92  //---------------------------------------------------------------------
94  //---------------------------------------------------------------------
96 
100  size_t size() const
101 #ifndef AIMS_GRAPH_SIZE_NO_DEPREC_WARNING
102  __attribute__((__deprecated__("use edgesSize() for "
103  "the number of edges. In a future release, size() will return the "
104  "number properties as it does in GenericObject")))
105 #endif
106  ;
110  size_t edgesSize() const;
111 
116  bool hasEdge(const Edge* edge) const;
117 
123  std::set<Edge*> edgesTo(const Vertex* vertex) const;
124 
126 
127  //---------------------------------------------------------------------
129  //---------------------------------------------------------------------
131 
136  iterator begin();
137 
142  iterator end();
143 
148  const_iterator begin() const;
149 
154  const_iterator end() const;
155 
160  reverse_iterator rbegin();
161 
166  reverse_iterator rend();
167 
172  const_reverse_iterator rbegin() const;
173 
178  const_reverse_iterator rend() const;
179 
181 
182  //---------------------------------------------------------------------
184  //---------------------------------------------------------------------
186 
190  std::set<Vertex*> neighbours() const;
191 
195  std::set<Vertex*> inNeighbours() const;
196 
200  std::set<Vertex*> outNeighbours() const;
201 
205  Vertex* randomNeighbour() const;
206 
208 
209 protected:
210 
211  //---------------------------------------------------------------------
213  //---------------------------------------------------------------------
215 
220  Vertex(std::string s);
221 
226  Vertex(const Vertex& x);
227 
232  virtual Vertex * cloneVertex() const;
233 
235 
236 private:
237 
238  //---------------------------------------------------------------------
240  //---------------------------------------------------------------------
242 
244  friend class Graph;
246  friend class GraphFactory;
247 
249 
250  //---------------------------------------------------------------------
252  //---------------------------------------------------------------------
254 
259  void addEdge(Edge* edge);
260 
265  void removeEdge(Edge* edge);
266 
268 
269  //---------------------------------------------------------------------
271  //---------------------------------------------------------------------
273 
276  Vertex& operator=(const Vertex&);
277 
279 
282  ESet _edges;
283 
284 };
285 
286 
287 //=============================================================================
288 // I N L I N E M E T H O D S
289 //=============================================================================
290 
291 inline
294 {
295  return _edges.begin();
296 }
297 
298 
299 inline
302 {
303  return _edges.end();
304 }
305 
306 
307 inline
310 {
311  return _edges.begin();
312 }
313 
314 
315 inline
317 Vertex::end() const
318 {
319  return _edges.end();
320 }
321 
322 
323 inline
326 {
327  return _edges.rbegin();
328 }
329 
330 
331 inline
334 {
335  return _edges.rend();
336 }
337 
338 
339 inline
342 {
343  return _edges.rbegin();
344 }
345 
346 
347 inline
350 {
351  return _edges.rend();
352 }
353 
354 
355 inline
356 std::set<Vertex*>
358 {
359  return outNeighbours();
360 }
361 
362 
363 namespace carto
364 {
366 }
367 
368 #endif
#define DECLARE_GENERIC_OBJECT_TYPE(T)
#define __deprecated__(msg)
iterator end()
Get the end of the edge collection.
Definition: vertex.h:301
std::set< Vertex * > neighbours() const
Same as outNeighbours.
Definition: vertex.h:357
The base class for graphs.
Definition: graph.h:71
iterator begin()
Get the beginning of the edge collection.
Definition: vertex.h:293
ESet::reference reference
Definition: vertex.h:76
ESet::pointer pointer
pointer is absent from MS Visual C++ / Intel Win32
Definition: vertex.h:74
reverse_iterator rend()
Get the end of the reversed edge collection.
Definition: vertex.h:333
The abstract base class for all types of edges; edges are created and managed by Graphs.
Definition: edge.h:68
ESet::const_iterator const_iterator
Definition: vertex.h:79
#define GRAPH_API
Definition: graph_config.h:46
ESet::iterator iterator
Definition: vertex.h:78
ESet::const_reference const_reference
Definition: vertex.h:77
Default abstract factory for graphs.
Definition: gfactory.h:71
ESet::const_reverse_iterator const_reverse_iterator
Definition: vertex.h:81
The abstract base class for graphs, vertices and edges.
Definition: graphobject.h:52
reverse_iterator rbegin()
Get the beginning of the reversed edge collection.
Definition: vertex.h:325
#define __attribute__(a)
ESet::value_type value_type
Definition: vertex.h:71
ESet::reverse_iterator reverse_iterator
Definition: vertex.h:80
Vertices are created and managed by Graphs.
Definition: vertex.h:63