graph  4.7.0
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  __attribute__((__deprecated__("use edgesSize() for "
102  "the number of edges. In a future release, size() will return the "
103  "number properties as it does in GenericObject")));
107  size_t edgesSize() const;
108 
113  bool hasEdge(const Edge* edge) const;
114 
120  std::set<Edge*> edgesTo(const Vertex* vertex) const;
121 
123 
124  //---------------------------------------------------------------------
126  //---------------------------------------------------------------------
128 
133  iterator begin();
134 
139  iterator end();
140 
145  const_iterator begin() const;
146 
151  const_iterator end() const;
152 
157  reverse_iterator rbegin();
158 
163  reverse_iterator rend();
164 
169  const_reverse_iterator rbegin() const;
170 
175  const_reverse_iterator rend() const;
176 
178 
179  //---------------------------------------------------------------------
181  //---------------------------------------------------------------------
183 
187  std::set<Vertex*> neighbours() const;
188 
192  std::set<Vertex*> inNeighbours() const;
193 
197  std::set<Vertex*> outNeighbours() const;
198 
202  Vertex* randomNeighbour() const;
203 
205 
206 protected:
207 
208  //---------------------------------------------------------------------
210  //---------------------------------------------------------------------
212 
217  Vertex(std::string s);
218 
223  Vertex(const Vertex& x);
224 
229  virtual Vertex * cloneVertex() const;
230 
232 
233 private:
234 
235  //---------------------------------------------------------------------
237  //---------------------------------------------------------------------
239 
241  friend class Graph;
243  friend class GraphFactory;
244 
246 
247  //---------------------------------------------------------------------
249  //---------------------------------------------------------------------
251 
256  void addEdge(Edge* edge);
257 
262  void removeEdge(Edge* edge);
263 
265 
266  //---------------------------------------------------------------------
268  //---------------------------------------------------------------------
270 
273  Vertex& operator=(const Vertex&);
274 
276 
279  ESet _edges;
280 
281 };
282 
283 
284 //=============================================================================
285 // I N L I N E M E T H O D S
286 //=============================================================================
287 
288 inline
289 Vertex::iterator
290 Vertex::begin()
291 {
292  return _edges.begin();
293 }
294 
295 
296 inline
299 {
300  return _edges.end();
301 }
302 
303 
304 inline
307 {
308  return _edges.begin();
309 }
310 
311 
312 inline
314 Vertex::end() const
315 {
316  return _edges.end();
317 }
318 
319 
320 inline
323 {
324  return _edges.rbegin();
325 }
326 
327 
328 inline
331 {
332  return _edges.rend();
333 }
334 
335 
336 inline
339 {
340  return _edges.rbegin();
341 }
342 
343 
344 inline
347 {
348  return _edges.rend();
349 }
350 
351 
352 inline
353 std::set<Vertex*>
355 {
356  return outNeighbours();
357 }
358 
359 
360 namespace carto
361 {
363 }
364 
365 #endif
#define DECLARE_GENERIC_OBJECT_TYPE(T)
iterator end()
Get the end of the edge collection.
Definition: vertex.h:298
std::set< Vertex * > neighbours() const
Same as outNeighbours.
Definition: vertex.h:354
The base class for graphs.
Definition: graph.h:71
iterator begin()
Get the beginning of the edge collection.
Definition: vertex.h:290
ESet::reference reference
Definition: vertex.h:76
STL namespace.
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:330
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:322
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