25 #ifndef PAGMO_TOPOLOGY_BASE_H
26 #define PAGMO_TOPOLOGY_BASE_H
28 #include <boost/graph/adjacency_list.hpp>
29 #include <boost/shared_ptr.hpp>
35 #include "../config.h"
36 #include "../serialization.h"
50 typedef boost::shared_ptr<base>
base_ptr;
79 struct edge_properties {
80 double migr_probability;
81 friend class boost::serialization::access;
82 template <
class Archive>
83 void serialize(Archive &ar,
const unsigned int)
85 ar & migr_probability;
93 typedef boost::adjacency_list<
96 boost::bidirectionalS,
104 typedef boost::graph_traits<graph_type>::vertex_iterator
v_iterator;
106 typedef boost::graph_traits<graph_type>::edge_iterator
e_iterator;
108 typedef boost::graph_traits<graph_type>::adjacency_iterator
a_iterator;
112 typedef boost::graph_traits<graph_type>::vertex_descriptor
v_descriptor;
133 virtual base_ptr clone()
const = 0;
135 virtual std::string get_name()
const;
136 std::string human_readable_terse()
const;
137 std::string human_readable()
const;
140 vertices_size_type get_number_of_vertices()
const;
141 edges_size_type get_number_of_edges()
const;
143 double get_average_shortest_path_length()
const;
144 double get_clustering_coefficient()
const;
145 std::vector<double> get_degree_distribution()
const;
146 bool are_adjacent(
const vertices_size_type &,
const vertices_size_type &)
const;
147 bool are_inv_adjacent(
const vertices_size_type &,
const vertices_size_type &)
const;
148 std::vector<vertices_size_type> get_v_adjacent_vertices(
const vertices_size_type &)
const;
149 std::vector<vertices_size_type> get_v_inv_adjacent_vertices(
const vertices_size_type &)
const;
150 edges_size_type get_num_adjacent_vertices(
const vertices_size_type &)
const;
151 edges_size_type get_num_inv_adjacent_vertices(
const vertices_size_type &)
const;
152 void set_weight(
double);
153 void set_weight(
const vertices_size_type &,
double);
154 void set_weight(
const vertices_size_type &,
const vertices_size_type &,
double);
155 double get_weight(
const vertices_size_type &,
const vertices_size_type &)
const;
161 std::pair<a_iterator,a_iterator> get_adjacent_vertices(
const vertices_size_type &)
const;
162 std::pair<ia_iterator,ia_iterator> get_inv_adjacent_vertices(
const vertices_size_type &)
const;
163 void add_edge(
const vertices_size_type &,
const vertices_size_type &);
164 void remove_edge(
const vertices_size_type &,
const vertices_size_type &);
165 void remove_all_edges();
166 std::pair<v_iterator,v_iterator> get_vertices()
const;
174 virtual void connect(
const vertices_size_type &idx) = 0;
176 virtual std::string human_readable_extra()
const;
178 void check_vertex_index(
const vertices_size_type &)
const;
179 void set_weight(
const e_descriptor &,
double);
180 double get_weight(
const e_descriptor &)
const;
181 friend class boost::serialization::access;
182 template <
class Archive>
183 void serialize(Archive &ar,
const unsigned int)
191 std::ostream __PAGMO_VISIBLE_FUNC &
operator<<(std::ostream &,
const base &);
boost::shared_ptr< base > base_ptr
Alias for shared pointer to base topology.
graph_type::edges_size_type edges_size_type
Edges size type.
boost::graph_traits< graph_type >::vertex_iterator v_iterator
Iterator over the vertices.
boost::graph_traits< graph_type >::edge_iterator e_iterator
Iterator over the edges.
graph_type::vertices_size_type vertices_size_type
Vertices size type.
boost::graph_traits< graph_type >::edge_descriptor e_descriptor
Edge descriptor.
boost::graph_traits< graph_type >::adjacency_iterator a_iterator
Iterator over adjacent vertices.
graph_type::inv_adjacency_iterator ia_iterator
Iterator over inversely adjacent vertices.
std::ostream & operator<<(std::ostream &s, const base &t)
Overload stream insertion operator for topology::base.
boost::graph_traits< graph_type >::vertex_descriptor v_descriptor
Vertex descriptor.