3 #include <boost/graph/adjacency_list.hpp> 4 #include <boost/graph/small_world_generator.hpp> 5 #include <boost/random/linear_congruential.hpp> 6 #include <boost/graph/graphviz.hpp> 9 typedef boost::adjacency_list<>
Graph;
10 typedef boost::small_world_iterator<boost::minstd_rand, Graph>
SWGen;
14 std::cout <<
"Usage: small_world nb_nodes connectivity rewiring_probability random_generator_seed" << std::endl;
15 std::cout <<
"Produces a small word network (See Boost Graph Library) in 'topo' format on the standard output" << std::endl;
19 int main(
int argc,
char ** argv)
25 std::stringstream stream;
27 Graph::vertices_size_type nbNodes = 0;
31 Graph::vertices_size_type k = 0;
36 double probability = 0.0;
38 stream >> probability;
47 boost::minstd_rand gen;
51 typedef boost::property_map<Graph, boost::vertex_index_t>::type IndexMap;
52 IndexMap index =
get(boost::vertex_index, g);
53 std::pair<Graph::edge_iterator,Graph::edge_iterator> pair = edges(g);
54 std::cout <<
"p top " << num_vertices(g) <<
" " << num_edges(g) << std::endl;
56 for(Graph::edge_iterator it = pair.first; it != pair.second; ++it)
58 std::cout <<
"c" << i <<
": n" << index[source(*it,g)] <<
", n" << index[target(*it,g)] <<
";" << std::endl;
int main(int argc, char **argv)
boost::adjacency_list Graph
boost::adjacency_list Graph
boost::small_world_iterator< boost::minstd_rand, Graph > SWGen