Loading...
Searching...
No Matches
Vertex.h
Go to the documentation of this file.
1/* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2
3 This file is part of the TerraLib - a Framework for building GIS enabled applications.
4
5 TerraLib is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 TerraLib is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with TerraLib. See COPYING. If not, write to
17 TerraLib Team at <terralib-team@terralib.org>.
18 */
19
20/*!
21 \file Vertex.h
22
23 \brief From the point of view of graph theory, vertices are treated
24 as featureless and indivisible objects, although they may have
25 additional structure depending on the application from which the
26 graph arises;for instance, a semantic network is a graph in
27 which the vertices represent concepts or classes of objects.
28*/
29
30#ifndef __TERRALIB_GRAPH_INTERNAL_VERTEX_H
31#define __TERRALIB_GRAPH_INTERNAL_VERTEX_H
32
33// Terralib Includes
34#include "../Config.h"
35#include "../Enums.h"
36
37// STL Includes
38#include <map>
39#include <string>
40#include <set>
41#include <vector>
42
43
44
45
46namespace te
47{
48 // Forward declarations
49 namespace dt { class AbstractData; }
50
51 namespace graph
52 {
53
54 /*!
55 \class Vertex
56
57 \brief From the point of view of graph theory, vertices are treated
58 as featureless and indivisible objects, although they may have
59 additional structure depending on the application from which the
60 graph arises;for instance, a semantic network is a graph in
61 which the vertices represent concepts or classes of objects.
62
63
64 \note The neighbour informartion has to be defined in
65 a appropriated graph implementation.
66 */
67
69 {
70 public:
71
72 /*!
73 \brief Constructor.
74
75 \param id The vertex identifier
76
77 \param isNew Flag used to indicate that the element is new
78
79 */
80 Vertex(int id, bool isNew = true);
81
82 /*! \brief Copy constructor. */
84
85 /*! \brief Default destructor. */
87
88 /*!
89 \brief It returns the vertex id
90
91 \return Integer with the vertex identifier
92 */
93 int getId();
94
95
96 /** @name Vertex Attribute Methods
97 * Method used to manager attributes from vertex object.
98 */
99 //@{
100
101 /*!
102 \brief It returns the vector of attributes associated with this element
103
104 \return A vector of AbstractData (can be any type of data)
105 */
106 std::vector<te::dt::AbstractData*>& getAttributes();
107
108 /*!
109 \brief This function is used to set the number of attributes associated with the vertex elements
110
111 \param size Integer value to define the attribute size
112
113 \note Its important to use this method after a new property was associated to a edge
114 Function defined in AbstractGraph addEdgeProperty.
115
116 */
117 void setAttributeVecSize(int size);
118
119 /*!
120 \brief Add a new attribute to this element
121
122 \param idx Index of the new attribute (must be a valid position)
123
124 \param ad AbstractData (can be any type of data)
125
126 */
128
129 /*!
130 \brief Remove a attribute associated with this element
131
132 \param idx Index of the attribute (must be a valid position)
133
134 */
135 void removeAttribute(int idx);
136
137 /*!
138 \brief Returns the Predecessors vector
139
140 \note This information only will be defined in the apropriated graph type
141
142 \return std::vector<int> reference
143
144 */
145 std::set<int>& getPredecessors();
146
147 /*!
148 \brief Returns the Successors vector
149
150 \note This information only will be defined in the apropriated graph type
151
152 \return std::vector<int> reference
153
154 */
155 std::set<int>& getSuccessors();
156
157 /*!
158 \brief Returns the Neighborhood vector
159
160 \note This information only will be defined in the apropriated graph type
161
162 \return std::vector<int> reference
163
164 */
165 std::set<int>& getNeighborhood();
166
167 /*!
168 \brief Flag used to indicate that this element was changed
169
170 \param flag Boolean value used to indicate the vertex state
171 */
172 void setDirty(bool flag);
173
174 /*!
175 \brief Used to verify the vertex state.
176
177 \return Boolean value used to indicate the vertex state
178 */
179 bool isDirty();
180
181 /*!
182 \brief Flag used to indicate that this element was a new one
183
184 \return Boolean value used to indicate the vertex state
185 */
186 bool isNew();
187
188 //@}
189
190 protected:
191 int m_vertexId; //!< This is the vertex unique identifier.
192
193 std::vector<te::dt::AbstractData*> m_attrs; //!< This is the list of all vertex attributes.
194
195 std::set<int> m_predecessors; //!< List of all input edges (used in bidirectional graph).
196
197 std::set<int> m_successors; //!< List of all output edges (used in directional graph).
198
199 std::set<int> m_neighborhood; //!< List of all neighbors edges (used in undirectional graph).
200
201 bool m_dirty; //!< Flag used to indicate that vertex was changed.
202
203 bool m_new; //!< Flag used to indicate if this element is a new one.
204 };
205 } // end namespace graph
206} // end namespace te
207
208#endif // __TERRALIB_GRAPH_INTERNAL_VERTEX_H
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:56
From the point of view of graph theory, vertices are treated as featureless and indivisible objects,...
Definition: Vertex.h:69
bool m_new
Flag used to indicate if this element is a new one.
Definition: Vertex.h:203
bool isNew()
Flag used to indicate that this element was a new one.
void setAttributeVecSize(int size)
This function is used to set the number of attributes associated with the vertex elements.
std::set< int > & getNeighborhood()
Returns the Neighborhood vector.
std::set< int > & getSuccessors()
Returns the Successors vector.
std::set< int > m_neighborhood
List of all neighbors edges (used in undirectional graph).
Definition: Vertex.h:199
int getId()
It returns the vertex id.
~Vertex()
Default destructor.
void addAttribute(int idx, te::dt::AbstractData *ad)
Add a new attribute to this element.
std::set< int > m_predecessors
List of all input edges (used in bidirectional graph).
Definition: Vertex.h:195
Vertex(te::graph::Vertex *rhs)
Copy constructor.
std::set< int > & getPredecessors()
Returns the Predecessors vector.
std::vector< te::dt::AbstractData * > & getAttributes()
It returns the vector of attributes associated with this element.
std::set< int > m_successors
List of all output edges (used in directional graph).
Definition: Vertex.h:197
bool m_dirty
Flag used to indicate that vertex was changed.
Definition: Vertex.h:201
void removeAttribute(int idx)
Remove a attribute associated with this element.
int m_vertexId
This is the vertex unique identifier.
Definition: Vertex.h:191
std::vector< te::dt::AbstractData * > m_attrs
This is the list of all vertex attributes.
Definition: Vertex.h:193
bool isDirty()
Used to verify the vertex state.
void setDirty(bool flag)
Flag used to indicate that this element was changed.
Vertex(int id, bool isNew=true)
Constructor.
TerraLib.
#define TEGRAPHEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:178