forked from Smorodov/Multitarget-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.h
More file actions
331 lines (270 loc) · 8.25 KB
/
Copy pathnode.h
File metadata and controls
331 lines (270 loc) · 8.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
/* This software is distributed under the GNU Lesser General Public License */
//==========================================================================
//
// node.h
//
//==========================================================================
// $Id: node.h,v 1.20 2003/11/27 13:36:56 raitner Exp $
#ifndef GTL_NODE_H
#define GTL_NODE_H
#include <GTL/GTL.h>
#include <GTL/edge.h>
#include <list>
__GTL_BEGIN_NAMESPACE
//--------------------------------------------------------------------------
// For MSVC 5.0 node.h has to be included before {node,edge}_data.h.
// So we only declare node_data here
//--------------------------------------------------------------------------
class node_data;
//--------------------------------------------------------------------------
// nodes
//--------------------------------------------------------------------------
/**
* @short A node in a graph
*/
class GTL_EXTERN node
{
public:
/**
* Default constructor. Creates an invalid node.
* The only way to obtain a valid node is through @ref
* graph#new_node Example:
* <pre>
* graph g;
* node n;
*
* n = g.new_node();
* </pre>
*
* @see graph#new_node
*/
node();
/**
* Returns the degree of the node, i. e.
* @ref node#outdeg + @ref node#indeg .
*/
int degree() const;
/**
* Returns the out degree of the node, i. e. the number of outgoing edges.
*/
int outdeg() const;
/**
* Returns the in degree of the node, i. e. the number of incoming edges.
*/
int indeg() const;
/**
* @internal
*/
int id() const;
/**
* Returns the node on the opposite side of <code>e</code>.
*
* @param e an edge incident to the node
*/
const node& opposite(GTL::edge e) const;
/**
* @internal
*/
nodes_t opposites(GTL::edge) const;
/**
* Returns true iff node is hidden.
*
* @return true iff node is hidden.
* @see graph#hide_edge
* @see graph#restore_edge
*/
bool is_hidden () const;
/**
* Returns the excentricity of the node, i.e. the maximum graph-theoretic
* distance to another node
*
* @return excentricity of node.
*/
int excentricity() const;
//================================================== Iterator types
/**
* @internal
*/
typedef edges_t::const_iterator in_edges_iterator;
/**
* @internal
*/
typedef edges_t::const_iterator out_edges_iterator;
/**
* @internal
*/
class inout_edges_iterator;
/**
* @internal
*/
class adj_nodes_iterator;
/**
* @internal
*/
class adj_edges_iterator;
//================================================== Iterators
/**
* Iterate through all adjacent nodes.
*
* @return start for iteration through all adjacent nodes
*/
adj_nodes_iterator adj_nodes_begin() const;
/**
* Iterate through all adjacent nodes.
*
* @return end for iteration through all adjacent nodes
*/
adj_nodes_iterator adj_nodes_end() const;
/**
* Iterate through all adjacent edges.
*
* @return start for iteration through all adjacent edges
*/
adj_edges_iterator adj_edges_begin() const;
/**
* Iterate through all adjacent edges.
*
* @return end for iteration through all adjacent edges
*/
adj_edges_iterator adj_edges_end() const;
/**
* Iterate through all incoming edges.
*
* @return start for iteration through all incoming edges
*/
in_edges_iterator in_edges_begin() const;
/**
* Iterate through all incoming edges.
*
* @return end for iteration through all incoming edges
*/
in_edges_iterator in_edges_end() const;
/**
* Iterate through all outgoing edges.
*
* @return start for iteration through all outgoing edges
*/
out_edges_iterator out_edges_begin() const;
/**
* Iterate through all outgoing edges.
*
* @return end for iteration through all outgoing edges
*/
out_edges_iterator out_edges_end() const;
/**
* Iterate through all incoming <em>and</em> outgoing edges.
*
* @return start for iteration through all incoming and outgoing edges
*/
inout_edges_iterator inout_edges_begin() const;
/**
* Iterate through all incoming <em>and</em> outgoing edges.
*
* @return end for iteration through all incoming and outgoing edges
*/
inout_edges_iterator inout_edges_end() const;
//================================================== Implementation
private:
node_data *data;
bool is_directed() const;
bool is_undirected() const;
friend class graph;
friend class edge;
friend class adj_edges_iterator;
GTL_EXTERN friend bool operator==(GTL::node, GTL::node);
GTL_EXTERN friend bool operator!=(GTL::node, GTL::node);
GTL_EXTERN friend bool operator<(GTL::node, GTL::node);
GTL_EXTERN friend std::ostream& operator<< (std::ostream& os, const node& n);
};
/**
* @short Iterator for adjacent edges of a node
*/
class GTL_EXTERN node::adj_edges_iterator
{
public:
using iterator_category = std::bidirectional_iterator_tag;
using value_type = GTL::edge;
// constructor
adj_edges_iterator();
adj_edges_iterator(GTL::node, bool);
// comparibility
bool operator==(const adj_edges_iterator&) const;
bool operator!=(const adj_edges_iterator&) const;
// operators
adj_edges_iterator &operator++();
adj_edges_iterator operator++(int);
adj_edges_iterator &operator--();
adj_edges_iterator operator--(int);
// dereferencing
const edge& operator*() const;
const edge* operator->() const;
private:
in_edges_iterator akt_edge[2], last_edge[2], begin_edge[2];
int inout; // in=0, out=1
bool directed; // graph directed ??
};
/**
* @short Iterator for all incident edges of a node
*/
class GTL_EXTERN node::inout_edges_iterator
{
public:
using iterator_category = std::bidirectional_iterator_tag;
using value_type = GTL::edge;
// constructor
inout_edges_iterator();
inout_edges_iterator(GTL::node n, bool start);
// comparibility
bool operator==(const inout_edges_iterator&) const;
bool operator!=(const inout_edges_iterator&) const;
// operators
inout_edges_iterator &operator++();
inout_edges_iterator operator++(int);
inout_edges_iterator &operator--();
inout_edges_iterator operator--(int);
// dereferencing
const edge& operator*() const;
const edge* operator->() const;
private:
in_edges_iterator akt_edge[2], last_edge, begin_edge;
int inout; // in=0, out=1
};
/**
* @short Iterator for adjacent nodes of a node
*/
class GTL_EXTERN node::adj_nodes_iterator
{
public:
using iterator_category = std::bidirectional_iterator_tag;
using value_type = GTL::node;
// constructor
adj_nodes_iterator();
adj_nodes_iterator(const node&, bool);
// comparibility
bool operator==(const adj_nodes_iterator&) const;
bool operator!=(const adj_nodes_iterator&) const;
// operators
adj_nodes_iterator &operator++();
adj_nodes_iterator operator++(int);
adj_nodes_iterator &operator--();
adj_nodes_iterator operator--(int);
// dereferencing
const node& operator*() const;
const node* operator->() const;
private:
adj_edges_iterator akt_edge;
node int_node;
};
__GTL_END_NAMESPACE
//--------------------------------------------------------------------------
// Iteration
//--------------------------------------------------------------------------
// #define forall_adj_nodes(v,w) GTL_FORALL(v,w,node::adj_nodes_iterator,adj_nodes_)
#define forall_out_edges(e,v) GTL_FORALL(e,v,GTL::node::out_edges_iterator,out_edges_)
#define forall_in_edges(e,v) GTL_FORALL(e,v,GTL::node::in_edges_iterator,in_edges_)
#define forall_inout_edges(e,v) GTL_FORALL(e,v,GTL::node::inout_edges_iterator,inout_edges_)
#define forall_adj_edges(e,v) GTL_FORALL(e,v,GTL::node::adj_edges_iterator,adj_edges_)
#endif // GTL_NODE_H
//--------------------------------------------------------------------------
// end of file
//--------------------------------------------------------------------------