Graph C++ Library
 All Classes Namespaces Files Functions Variables Typedefs Groups Pages
base_undirected_vertex.hpp
Go to the documentation of this file.
1 
10 #ifndef BASE_UNDIRECTED_VERTEX_HPP_INCLUDED
11 #define BASE_UNDIRECTED_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_undirected_vertex : public base_vertex<EdgeAttributesType>
34  {
35  // ============================================================================================
36  // *** Objects related to the vertex.
37  protected:
38  const unsigned int id_degree;
39  // ============================================================================================
40  // *** Information about the vertex.
41  private:
42  unsigned int nb_triangles;
43  double local_clustering_coefficient;
44  // ============================================================================================
45  // *** Member functions.
46  public:
49  unsigned int get_degree();
50  unsigned int get_nb_triangles();
52  void set_nb_triangles(unsigned int _value);
53  void neighbour_insert(EdgeAttributesType _edge);
56  protected:
58  };
59 
60 } // End of namespace gcl.
61 
62 
63 
64 // ================================================================================================
65 // ================================================================================================
66 template <class EdgeAttributesType>
68 
69 // ================================================================================================
70 // ================================================================================================
71 template <class EdgeAttributesType>
73 {
74  return this->get_base_vertex_degrees(id_degree);
75 }
76 
77 // ================================================================================================
78 // ================================================================================================
79 template <class EdgeAttributesType>
81 {
82  return nb_triangles;
83 }
84 
85 // ================================================================================================
86 // ================================================================================================
87 template <class EdgeAttributesType>
89 {
90  return local_clustering_coefficient;
91 }
92 
93 // ================================================================================================
94 // ================================================================================================
95 template <class EdgeAttributesType>
97 {
98  // Sets the number of triangles.
99  nb_triangles = _value;
100  // Computes the local clustering coefficient.
101  local_clustering_coefficient = ( 2. * nb_triangles ) / ( this->get_degree() * ( this->get_degree() - 1. ) );
102 }
103 
104 // ================================================================================================
105 // ================================================================================================
106 template <class EdgeAttributesType>
108 {
109  this->base_vertex_neighbour_insert(id_degree, _edge);
110 }
111 
112 // ================================================================================================
113 // ================================================================================================
114 template <class EdgeAttributesType>
116 {
117  return this->base_vertex_neighbour_begin(id_degree);
118 }
119 
120 // ================================================================================================
121 // ================================================================================================
122 template <class EdgeAttributesType>
124 {
125  return this->base_vertex_neighbour_end(id_degree);
126 }
127 
128 // ================================================================================================
129 // ================================================================================================
130 template <class EdgeAttributesType>
132 {
133  // Resets the number of types of vertices.
134  this->set_nb_of_types_of_degrees(1);
135  // Resets the variables inherited from base_vertex.
136  this->base_vertex_clear();
137  // Resets the number of triangles.
138  nb_triangles = 0;
139  // Resets the local clustering coefficient.
140  local_clustering_coefficient = 0;
141 }
142 
143 
144 
145 #endif // BASE_UNDIRECTED_VERTEX_HPP_INCLUDED
std::list< EdgeAttributesType >::iterator iterator
Typedef for iterators used to browse the neighbourhood of the vertex.
Definition: base_vertex.hpp:35
unsigned int get_nb_triangles()
Returns the number of triangles the vertex is a part of.
Definition: base_undirected_vertex.hpp:80
Virtual base class for vertices in graphs.
base_undirected_vertex()
Constructor.
Definition: base_undirected_vertex.hpp:67
virtual ~base_undirected_vertex()
Destructor.
Definition: base_undirected_vertex.hpp:48
const unsigned int id_degree
Index corresponding to the degree in degree-related vectors.
Definition: base_undirected_vertex.hpp:38
unsigned int get_degree()
Returns the degree of the vertex.
Definition: base_undirected_vertex.hpp:72
void base_undirected_vertex_clear()
Reinitializes the vertex.
Definition: base_undirected_vertex.hpp:131
gcl::base_vertex< EdgeAttributesType >::iterator neighbour_end()
Returns an operator pointing at the end the neighbours container.
Definition: base_undirected_vertex.hpp:123
void neighbour_insert(EdgeAttributesType _edge)
Adds a vertex to the neighbourhood of the vertex.
Definition: base_undirected_vertex.hpp:107
void set_nb_triangles(unsigned int _value)
Sets the number of triangles the vertex is a part of.
Definition: base_undirected_vertex.hpp:96
Virtual template base class for vertices in undirected graphs.
Definition: base_undirected_vertex.hpp:33
gcl::base_vertex< EdgeAttributesType >::iterator neighbour_begin()
Returns an operator pointing at the beginning the neighbours container.
Definition: base_undirected_vertex.hpp:115
Virtual template base class for vertices in graphs.
Definition: base_vertex.hpp:30
double get_local_clustering_coefficient()
Returns the local clustering coefficient.
Definition: base_undirected_vertex.hpp:88