10 #ifndef BASE_GRAPH_HPP_INCLUDED
11 #define BASE_GRAPH_HPP_INCLUDED
32 template <
class VertexType>
38 std::vector< VertexType > the_graph;
39 unsigned int nb_of_types_of_degrees;
43 std::string type_of_graph;
44 unsigned int nb_vertices;
45 unsigned int nb_edges;
47 std::vector< unsigned int > min_degrees;
48 std::vector< unsigned int > max_degrees;
49 std::vector< double > avg_degrees;
50 unsigned int nb_zerodegree_vertices;
54 bool have_the_degree_distributions_been_surveyed;
67 virtual void clear() = 0;
85 template <
class VertexType>
93 template <
class VertexType>
101 template <
class VertexType>
109 template <
class VertexType>
112 return nb_zerodegree_vertices;
117 template <
class VertexType>
120 return &the_graph[_id];
125 template <
class VertexType>
128 nb_vertices = _value;
129 the_graph.resize(nb_vertices);
134 template <
class VertexType>
142 template <
class VertexType>
145 type_of_graph = _type_of_graph;
150 template <
class VertexType>
153 nb_of_types_of_degrees = _value;
158 template <
class VertexType>
161 return min_degrees[_type];
166 template <
class VertexType>
169 return max_degrees[_type];
174 template <
class VertexType>
177 return avg_degrees[_type];
182 template <
class VertexType>
186 unsigned int d, tot_degree;
189 min_degrees.resize(nb_of_types_of_degrees,nb_vertices);
191 max_degrees.resize(nb_of_types_of_degrees,0);
193 avg_degrees.resize(nb_of_types_of_degrees,0);
194 for(
unsigned int n(0); n<nb_vertices; ++n)
199 for(
unsigned int t(0); t<nb_of_types_of_degrees; ++t)
201 tot_degree += the_graph[n].get_base_vertex_degrees(t);
206 ++nb_zerodegree_vertices;
210 for(
unsigned int t(0); t<nb_of_types_of_degrees; ++t)
213 d = the_graph[n].get_base_vertex_degrees(t);
218 if(d < min_degrees[t])
220 if(d > max_degrees[t])
226 for(
unsigned int t(0); t<nb_of_types_of_degrees; ++t)
228 avg_degrees[t] /= nb_vertices;
249 have_the_degree_distributions_been_surveyed =
true;
254 template <
class VertexType>
260 type_of_graph =
"Base graph";
269 min_degrees.resize(nb_of_types_of_degrees,0);
271 max_degrees.resize(nb_of_types_of_degrees,0);
273 avg_degrees.resize(nb_of_types_of_degrees,0);
274 nb_zerodegree_vertices = 0;
275 have_the_degree_distributions_been_surveyed =
false;
280 #endif // BASE_GRAPH_HPP_INCLUDED
double get_base_graph_avg_degrees(unsigned int _type)
Returns the average degree found in the graph.
Definition: base_graph.hpp:175
unsigned int get_nb_zerodegree_vertices()
Returns the number of vertices with no edge.
Definition: base_graph.hpp:110
VertexType * operator()(unsigned int _id)
Returns a VertexType object corresponding to the _id-th vertex.
Definition: base_graph.hpp:118
virtual void write_edgelist(std::string _name)=0
Exports the undirected graph to an edgelist.
unsigned int get_base_graph_min_degrees(unsigned int _type)
Returns the minimal degree found in the graph.
Definition: base_graph.hpp:159
void base_graph_clear()
Reinitializes the graph (inherited variables).
Definition: base_graph.hpp:255
void survey_degrees_distribution()
Computes the quantities related to the degrees distribution.
Definition: base_graph.hpp:183
unsigned int get_nb_vertices()
Returns the number of vertices.
Definition: base_graph.hpp:94
Virtual template base class for graph objects.
Definition: base_graph.hpp:33
void set_nb_vertices(unsigned int _value)
Sets the number of vertices.
Definition: base_graph.hpp:126
virtual ~base_graph()
Destructor.
Definition: base_graph.hpp:59
virtual void clear()=0
Reinitializes the graph (specific variables).
void set_type_of_graph(std::string _type_of_graph)
Sets the type of graph.
Definition: base_graph.hpp:143
unsigned int get_nb_edges()
Returns the number of edges.
Definition: base_graph.hpp:102
std::string get_type_of_graph()
Returns the type of graph.
Definition: base_graph.hpp:86
void set_nb_edges(unsigned int _value)
Sets the number of edges.
Definition: base_graph.hpp:135
unsigned int get_base_graph_max_degrees(unsigned int _type)
Returns the maximal degree found in the graph.
Definition: base_graph.hpp:167
base_graph()
Constructor.
Definition: base_graph.hpp:58
void set_nb_of_types_of_degrees(unsigned int _value)
Sets the number of types of degrees.
Definition: base_graph.hpp:151