GraphLibrary  0.0.1
A simple library that implements various graph algorithms.
 All Classes Namespaces Files Functions Variables Typedefs Macros
Property.hpp
Go to the documentation of this file.
1 #ifndef GL_PROPERTY_HPP
2 #define GL_PROPERTY_HPP
3 
4 namespace gl {
5 
7 // Property Class declaration
9 
14 class Property
15 {
16 public:
18 
19  Property(const idx_t &numNodes = 0, const std::string &label = "Graph") : numNodes_(numNodes), label_(label), numEdges_(0) {}
20 
21  Property(const Property&) = default;
22  Property(Property&&) noexcept = default;
23  Property &operator=(const Property&) = default;
24  Property &operator=(Property&&) noexcept = default;
25  ~Property() = default;
26 
31  bool operator== (const Property& rhs) const;
36  bool operator!= (const Property& rhs) const;
46  inline idx_t numNodes() const;
51  inline void numNodes(const idx_t &numNodes);
56  inline void numNodesIncrement(const idx_t &increment = 1);
61  inline void numNodesDecrement(const idx_t &decrement = 1);
63 
72  inline idx_t numEdges() const;
77  inline void numEdges(const idx_t &numEdges);
82  inline void numEdgesIncrement(const idx_t &increment = 1);
87  inline void numEdgesDecrement(const idx_t &decrement = 1);
89 
98  inline std::string label() const;
103  inline void label(const std::string &label);
105 
106 private:
109  std::string label_;
110 };
111 
113 // Property function implementations
115 
116 #ifndef DOXYGEN_SHOULD_SKIP_THIS
117 
118 // equality operator
119 bool Property::operator== (const Property& rhs) const
120 {
121  return numNodes_ == rhs.numNodes_
122  && numEdges_ == rhs.numEdges_
123  && label_ == rhs.label_;
124 }
125 // inequality operator
126 bool Property::operator!= (const Property& rhs) const
127 {
128  return !operator==(rhs);
129 }
130 
131 // getter for numNodes
132 inline typename Property::idx_t Property::numNodes() const {
133  return numNodes_;
134 }
135 // setter for numNodes
136 inline void Property::numNodes(const typename Property::idx_t& numNodes) {
137  numNodes_ = numNodes;
138 }
139 
140 // increment for numNodes
141 inline void Property::numNodesIncrement (const typename Property::idx_t& increment) {
142  numNodes_ += increment;
143 }
144 // decrement for numNodes
145 inline void Property::numNodesDecrement (const typename Property::idx_t& decrement) {
146  GL_ASSERT(decrement <= numNodes_,"Property::numNodesDecrement | Decrement results in negative number of nodes")
147  numNodes_ -= decrement;
148 }
149 
150 // getter for numEdges
151 inline typename Property::idx_t Property::numEdges() const {
152  return numEdges_;
153 }
154 // setter for numEdges
155 inline void Property::numEdges(const typename Property::idx_t& numEdges) {
156  numEdges_ = numEdges;
157 }
158 
159 // increment for numEdges
160 inline void Property::numEdgesIncrement (const typename Property::idx_t& increment) {
161  numEdges_ += increment;
162 }
163 // decrement for numEdges
164 inline void Property::numEdgesDecrement (const typename Property::idx_t& decrement) {GL_ASSERT(decrement <= numNodes_,"Property::numEdgesDecrement | Decrement results in negative number of edges")
165  numEdges_ -= decrement;
166 }
167 
168 // getter for label
169 inline std::string Property::label() const {
170  return label_;
171 }
172 // setter for label
173 inline void Property::label(const std::string& label) {
174  label_ = label;
175 }
176 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
177 
178 } // namespace gl
179 
180 #endif // GL_PROPERTY_HPP
idx_t numNodes() const
Gets the number of nodes in the graph.
bool operator!=(const Property &rhs) const
Check whether two propertes are not equal.
std::string label() const
Gets the label of the graph.
void numNodesIncrement(const idx_t &increment=1)
Increments the number of nodes in the graph.
idx_t numEdges_
Number of edges in the graph.
Definition: Property.hpp:108
#define GL_ASSERT(EXPR, ERROR_MSG)
Custom assert that supports attaching a message.
Definition: gl_assert.hpp:14
idx_t numNodes_
Number of nodes in the graph.
Definition: Property.hpp:107
std::size_t index_type
Definition: gl_base.hpp:18
void numNodesDecrement(const idx_t &decrement=1)
Decrements the number of nodes in the graph.
void numEdgesIncrement(const idx_t &increment=1)
Increments the number of edges in the graph.
bool operator==(const Property &rhs) const
Check whether two propertes are equal.
Property(const idx_t &numNodes=0, const std::string &label="Graph")
Definition: Property.hpp:19
gl::index_type idx_t
Definition: Property.hpp:17
idx_t numEdges() const
Gets the number of edges in the graph.
std::string label_
Label of the graph.
Definition: Property.hpp:109
void numEdgesDecrement(const idx_t &decrement=1)
Decrements the number of edges in the graph.
Stores the properties of a Graph.
Definition: Property.hpp:14