graph 6.0.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
53class 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
66private:
67 typedef std::set<Edge*> ESet;
68
69
70public:
71 typedef ESet::value_type value_type;
72#ifndef _WIN32
74 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
161
167
173
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
206
208
209 // from GenericObject
210 virtual std::string type() const CARTO_OVERRIDE
211 { return "Vertex"; }
212
213protected:
214
215 //---------------------------------------------------------------------
217 //---------------------------------------------------------------------
219
224 Vertex(std::string s);
225
230 Vertex(const Vertex& x);
231
236 virtual Vertex * cloneVertex() const;
237
239
240private:
241
242 //---------------------------------------------------------------------
244 //---------------------------------------------------------------------
246
248 friend class Graph;
250 friend class GraphFactory;
251
253
254 //---------------------------------------------------------------------
256 //---------------------------------------------------------------------
258
263 void addEdge(Edge* edge);
264
269 void removeEdge(Edge* edge);
270
272
273 //---------------------------------------------------------------------
275 //---------------------------------------------------------------------
277
280 Vertex& operator=(const Vertex&);
281
283
286 ESet _edges;
287
288};
289
290
291//=============================================================================
292// I N L I N E M E T H O D S
293//=============================================================================
294
295inline
298{
299 return _edges.begin();
300}
301
302
303inline
306{
307 return _edges.end();
308}
309
310
311inline
314{
315 return _edges.begin();
316}
317
318
319inline
322{
323 return _edges.end();
324}
325
326
327inline
330{
331 return _edges.rbegin();
332}
333
334
335inline
338{
339 return _edges.rend();
340}
341
342
343inline
346{
347 return _edges.rbegin();
348}
349
350
351inline
354{
355 return _edges.rend();
356}
357
358
359inline
360std::set<Vertex*>
362{
363 return outNeighbours();
364}
365
366
367namespace carto
368{
370}
371
372#endif
#define CARTO_OVERRIDE
#define __deprecated__(msg)
#define __attribute__(a)
The abstract base class for all types of edges; edges are created and managed by Graphs.
Definition edge.h:69
GraphObject(const std::string &s)
The programmer should not call the constructor of an abstract base class.
Vertices are created and managed by Graphs.
Definition vertex.h:64
std::set< Edge * > edgesTo(const Vertex *vertex) const
Returns the edges linking this vertex to a given vertex.
ESet::reverse_iterator reverse_iterator
Definition vertex.h:80
Vertex * randomNeighbour() const
Return a random neighbour (CAUTION!
Vertex(std::string s)
The programmer should not call the constructor.
bool hasEdge(const Edge *edge) const
Is a given edge attached to this vertex?
size_t edgesSize() const
The edgesSize of a vertex is the number of attached edges.
std::set< Vertex * > outNeighbours() const
Find the vertices for which this vertex is the source.
virtual std::string type() const CARTO_OVERRIDE
Definition vertex.h:210
iterator begin()
Get the beginning of the edge collection.
Definition vertex.h:297
ESet::value_type value_type
Definition vertex.h:71
std::set< Vertex * > inNeighbours() const
Find the vertices for which this vertex is the sink.
iterator end()
Get the end of the edge collection.
Definition vertex.h:305
ESet::const_reference const_reference
Definition vertex.h:77
size_t size() const __attribute__((__deprecated__("use edgesSize() for " "the number of edges. In a future release
friend class GraphFactory
export the constructors
Definition vertex.h:250
virtual ~Vertex()
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:337
ESet::reference reference
Definition vertex.h:76
ESet::const_reverse_iterator const_reverse_iterator
Definition vertex.h:81
std::set< Vertex * > neighbours() const
Same as outNeighbours.
Definition vertex.h:361
ESet::iterator iterator
Definition vertex.h:78
virtual Vertex * cloneVertex() const
The programmer should not clone.
ESet::const_iterator const_iterator
Definition vertex.h:79
reverse_iterator rbegin()
Get the beginning of the reversed edge collection.
Definition vertex.h:329
friend class Graph
export addEdge and removeEdge
Definition vertex.h:248
Vertex(const Vertex &x)
The programmer should not call the copy constructor.
#define GRAPH_API
#define DECLARE_GENERIC_OBJECT_TYPE(T)