10 #ifndef BASE_WEIGHTED_UNDIRECTED_GRAPH_HPP_INCLUDED
11 #define BASE_WEIGHTED_UNDIRECTED_GRAPH_HPP_INCLUDED
36 template <
class VertexType>
77 template <
class VertexType>
85 template <
class VertexType>
93 template <
class VertexType>
101 template <
class VertexType>
109 template <
class VertexType>
117 template <
class VertexType>
125 template <
class VertexType>
129 std::ofstream edgelist_file;
131 std::string edgelist_filename = _name +
"_edgelist.dat";
132 std::string node1_str;
134 typename VertexType::iterator it, end;
136 edgelist_file.open(edgelist_filename.c_str(), std::ios_base::out);
137 if( !edgelist_file.is_open() )
139 std::cout <<
"Could not open file: " << edgelist_filename <<
"." << std::endl;
143 for(
unsigned int node1(0), node2, nn(this->get_nb_vertices()); node1<nn; ++node1)
146 it = (*this)(node1)->neighbour_begin();
147 end = (*this)(node1)->neighbour_end();
148 node1_str = (*this)(node1)->get_name();
154 edgelist_file << node1_str <<
" " << (*this)(node2)->get_name() <<
" " << it->weight << std::endl;
159 edgelist_file.close();
164 template <
class VertexType>
168 this->survey_degrees_distribution();
170 this->survey_triangles();
172 this->compute_clustering_coefficients();
174 this->survey_strength_distribution();
176 this->survey_weight_distribution();
181 template <
class VertexType>
187 min_strength = this->get_nb_vertices();
191 for(
unsigned int n(0), nn(this->get_nb_vertices()); n<nn; ++n)
194 s = (*this)(n)->get_strength();
204 avg_strength /= this->get_nb_vertices();
209 template <
class VertexType>
215 typename VertexType::iterator it, end;
217 min_weight = this->get_nb_vertices();
221 for(
unsigned int v1(0), v2, nn(this->get_nb_vertices()); v1<nn; ++v1)
224 it = (*this)(v1)->neighbour_begin();
225 end = (*this)(v1)->neighbour_end();
247 avg_weight /= this->get_nb_edges();
252 template <
class VertexType>
256 this->base_undirected_graph_clear();
271 #endif // BASE_WEIGHTED_UNDIRECTED_GRAPH_HPP_INCLUDED
void survey_weight_distribution()
Fills the weight distribution and related quantities.
Definition: base_weighted_undirected_graph.hpp:210
double get_min_weight()
Returns the minimal weight found in the graph.
Definition: base_weighted_undirected_graph.hpp:102
double get_max_strength()
Returns the maximal strength found in the graph.
Definition: base_weighted_undirected_graph.hpp:86
virtual void write_graph_properties(std::string _name)=0
Exports the graph's properties.
Virtual base class for undirected graphs.
double get_max_weight()
Returns the maximal weight found in the graph.
Definition: base_weighted_undirected_graph.hpp:110
Virtual template base class for undirected graph objects.
Definition: base_undirected_graph.hpp:37
virtual ~base_weighted_undirected_graph()
Destructor.
Definition: base_weighted_undirected_graph.hpp:54
virtual void write_vertices_properties(std::string _name)=0
Exports the vertices' properties.
void write_edgelist(std::string _name)
Exports the directed graph to an edgelist.
Definition: base_weighted_undirected_graph.hpp:126
double get_avg_strength()
Returns the average strength found in the graph.
Definition: base_weighted_undirected_graph.hpp:94
void analyse_structural_properties()
Computes a set of structural properties.
Definition: base_weighted_undirected_graph.hpp:165
void survey_strength_distribution()
Fills the strength distribution and related quantities.
Definition: base_weighted_undirected_graph.hpp:182
double get_avg_weight()
Returns the average weight found in the graph.
Definition: base_weighted_undirected_graph.hpp:118
void base_weighted_undirected_graph_clear()
Reinitializes the graph (inherited variables).
Definition: base_weighted_undirected_graph.hpp:253
double get_min_strength()
Returns the minimal strength found in the graph.
Definition: base_weighted_undirected_graph.hpp:78
base_weighted_undirected_graph()
Constructor.
Definition: base_weighted_undirected_graph.hpp:53
Virtual template base class for weighted undirected graph objects.
Definition: base_weighted_undirected_graph.hpp:37