Graph C++ Library
 All Classes Namespaces Files Functions Variables Typedefs Groups Pages
base_directed_vertex.hpp
Go to the documentation of this file.
1 
10 #ifndef BASE_DIRECTED_VERTEX_HPP_INCLUDED
11 #define BASE_DIRECTED_VERTEX_HPP_INCLUDED
12 
13 // Standard Library
14 #include <list>
15 #include <string>
16 #include <vector>
17 // Graph C++ Library
18 #include "base_vertex.hpp"
19 
21 namespace gcl
22 {
23 
32  template <class EdgeAttributesType>
33  class base_directed_vertex : public base_vertex<EdgeAttributesType>
34  {
35  // ============================================================================================
36  // *** Objects related to the vertex.
37  private:
38  const unsigned int id_in_degree;
39  const unsigned int id_out_degree;
40  // ============================================================================================
41  // *** Information about the vertex.
42  private:
43  unsigned int undirected_projection_degree;
44  unsigned int nb_undirected_projection_triangles;
45  double local_undirected_projection_clustering_coefficient;
46  unsigned int nb_reciprocal_edges;
47  // ============================================================================================
48  // *** Member functions.
49  public:
51  virtual ~base_directed_vertex() {}
52  unsigned int get_in_degree();
53  unsigned int get_out_degree();
54  unsigned int get_undirected_projection_degree();
55  unsigned int get_nb_reciprocal_edges();
58  void set_nb_undirected_projection_triangles(unsigned int _value);
59  void set_nb_reciprocal_edges(unsigned int _value);
60  void in_neighbour_insert(EdgeAttributesType _edge);
61  void out_neighbour_insert(EdgeAttributesType _edge);
66  protected:
68  };
69 
70 } // End of namespace gcl.
71 
72 
73 
74 // ================================================================================================
75 // ================================================================================================
76 template <class EdgeAttributesType>
78 
79 // ================================================================================================
80 // ================================================================================================
81 template <class EdgeAttributesType>
83 {
84  return this->get_base_vertex_degrees(id_in_degree);
85 }
86 
87 // ================================================================================================
88 // ================================================================================================
89 template <class EdgeAttributesType>
91 {
92  return this->get_base_vertex_degrees(id_out_degree);
93 }
94 
95 // ================================================================================================
96 // ================================================================================================
97 template <class EdgeAttributesType>
99 {
100  return undirected_projection_degree;
101 }
102 
103 // ================================================================================================
104 // ================================================================================================
105 template <class EdgeAttributesType>
107 {
108  return nb_reciprocal_edges;
109 }
110 
111 // ================================================================================================
112 // ================================================================================================
113 template <class EdgeAttributesType>
115 {
116  return nb_undirected_projection_triangles;
117 }
118 
119 // ================================================================================================
120 // ================================================================================================
121 template <class EdgeAttributesType>
123 {
124  return local_undirected_projection_clustering_coefficient;
125 }
126 
127 // ================================================================================================
128 // ================================================================================================
129 template <class EdgeAttributesType>
131 {
132  // Sets the number of triangles.
133  nb_undirected_projection_triangles = _value;
134  // Computes the local clustering coefficient.
135  local_undirected_projection_clustering_coefficient = ( 2. * nb_undirected_projection_triangles ) / (undirected_projection_degree * (undirected_projection_degree - 1));
136 }
137 
138 // ================================================================================================
139 // ================================================================================================
140 template <class EdgeAttributesType>
142 {
143  // Sets the number of reciprocal edges.
144  nb_reciprocal_edges = _value;
145  // Computes the projected undirected degree.
146  undirected_projection_degree = this->get_out_degree() + this->get_in_degree() - ( this->get_nb_reciprocal_edges() / 2 ) ;
147 }
148 
149 // ================================================================================================
150 // ================================================================================================
151 template <class EdgeAttributesType>
153 {
154  this->base_vertex_neighbour_insert(id_in_degree, _edge);
155 }
156 
157 // ================================================================================================
158 // ================================================================================================
159 template <class EdgeAttributesType>
161 {
162  this->base_vertex_neighbour_insert(id_out_degree, _edge);
163 }
164 
165 // ================================================================================================
166 // ================================================================================================
167 template <class EdgeAttributesType>
169 {
170  return this->base_vertex_neighbour_begin(id_in_degree);
171 }
172 
173 // ================================================================================================
174 // ================================================================================================
175 template <class EdgeAttributesType>
177 {
178  return this->base_vertex_neighbour_end(id_in_degree);
179 }
180 
181 // ================================================================================================
182 // ================================================================================================
183 template <class EdgeAttributesType>
185 {
186  return this->base_vertex_neighbour_begin(id_out_degree);
187 }
188 
189 // ================================================================================================
190 // ================================================================================================
191 template <class EdgeAttributesType>
193 {
194  return this->base_vertex_neighbour_end(id_out_degree);
195 }
196 
197 // ================================================================================================
198 // ================================================================================================
199 template <class EdgeAttributesType>
201 {
202  // Resets the number of types of vertices.
203  this->set_nb_of_types_of_degrees(2);
204  // Resets the variables inherited from base_vertex.
205  this->base_vertex_clear();
206  // Resets various objects.
207  nb_reciprocal_edges = 0;
208  nb_undirected_projection_triangles = 0;
209  local_undirected_projection_clustering_coefficient = 0;
210  undirected_projection_degree = 0;
211 }
212 
213 
214 
215 #endif // BASE_DIRECTED_VERTEX_HPP_INCLUDED
double get_local_undirected_projection_clustering_coefficient()
Returns the local clustering coefficient (regardless of the direction of the edges).
Definition: base_directed_vertex.hpp:122
std::list< EdgeAttributesType >::iterator iterator
Typedef for iterators used to browse the neighbourhood of the vertex.
Definition: base_vertex.hpp:35
void in_neighbour_insert(EdgeAttributesType _edge)
Adds a vertex to the in neighbourhood of the vertex.
Definition: base_directed_vertex.hpp:152
virtual ~base_directed_vertex()
Destructor.
Definition: base_directed_vertex.hpp:51
unsigned int get_out_degree()
Returns the degree of the vertex.
Definition: base_directed_vertex.hpp:90
gcl::base_vertex< EdgeAttributesType >::iterator in_neighbour_end()
Returns an operator pointing at the end the in neighbours container.
Definition: base_directed_vertex.hpp:176
gcl::base_vertex< EdgeAttributesType >::iterator in_neighbour_begin()
Returns an operator pointing at the beginning the in neighbours container.
Definition: base_directed_vertex.hpp:168
Virtual base class for vertices in graphs.
void base_directed_vertex_clear()
Reinitializes the vertex.
Definition: base_directed_vertex.hpp:200
void set_nb_undirected_projection_triangles(unsigned int _value)
Sets the number of triangles the vertex is a part of (regardless of the direction of the edges)...
Definition: base_directed_vertex.hpp:130
unsigned int get_nb_reciprocal_edges()
Returns the number of reciprocal edges the vertex has.
Definition: base_directed_vertex.hpp:106
void set_nb_reciprocal_edges(unsigned int _value)
Sets the number of reciprocal edges the vertiex has.
Definition: base_directed_vertex.hpp:141
gcl::base_vertex< EdgeAttributesType >::iterator out_neighbour_end()
Returns an operator pointing at the end the out neighbours container.
Definition: base_directed_vertex.hpp:192
Virtual template base class for vertices in directed graphs.
Definition: base_directed_vertex.hpp:33
unsigned int get_nb_undirected_projection_triangles()
Returns the number of triangles the vertex is a part of (regardless of the direction of the edges)...
Definition: base_directed_vertex.hpp:114
base_directed_vertex()
Constructor.
Definition: base_directed_vertex.hpp:77
unsigned int get_undirected_projection_degree()
Returns the degree that the vertex has in the undirected version of the directed graph.
Definition: base_directed_vertex.hpp:98
Virtual template base class for vertices in graphs.
Definition: base_vertex.hpp:30
gcl::base_vertex< EdgeAttributesType >::iterator out_neighbour_begin()
Returns an operator pointing at the beginning the out neighbours container.
Definition: base_directed_vertex.hpp:184
void out_neighbour_insert(EdgeAttributesType _edge)
Adds a vertex to the out neighbourhood of the vertex.
Definition: base_directed_vertex.hpp:160
unsigned int get_in_degree()
Returns the degree of the vertex.
Definition: base_directed_vertex.hpp:82