本文整理汇总了C++中graph::get_node_out_degree方法的典型用法代码示例。如果您正苦于以下问题:C++ graph::get_node_out_degree方法的具体用法?C++ graph::get_node_out_degree怎么用?C++ graph::get_node_out_degree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graph
的用法示例。
在下文中一共展示了graph::get_node_out_degree方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_graph_details
string CDLib::get_graph_details(const graph& g)
{
ostringstream oss;
oss << "Number of Nodes: " << g.get_num_nodes() << endl;
oss << "Number of Edges: " << g.get_num_edges() << endl;
oss << "Number of Self Edges: " << g.get_num_self_edges() << endl;
oss << "Total Weight: " << g.get_total_weight() << endl;
oss << "Weight of Self Edges: " << g.get_self_edges_weight() << endl;
vector<id_type> in_degrees(g.get_num_nodes(),0),out_degrees(g.get_num_nodes(),0);
vector<double> in_weights(g.get_num_nodes(),0.0),out_weights(g.get_num_nodes(),0.0);
for(id_type i=0;i<g.get_num_nodes();i++)
{
in_degrees[i] = g.get_node_in_degree(i);
out_degrees[i] = g.get_node_out_degree(i);
in_weights[i] = g.get_node_in_weight(i);
out_weights[i] = g.get_node_out_weight(i);
}
oss << "In Degrees" << endl;
oss << "Min\tMedian\tMax\tMean\tVariance" << endl;
oss << statistics_string(in_degrees,"\t") << endl;
oss << "Out Degrees" << endl;
oss << "Min\tMedian\tMax\tMean\tVariance" << endl;
oss << statistics_string(out_degrees,"\t") << endl;
oss << "In Weights" << endl;
oss << "Min\tMedian\tMax\tMean\tVariance" << endl;
oss << statistics_string(in_weights,"\t") << endl;
oss << "Out Weights" << endl;
oss << "Min\tMedian\tMax\tMean\tVariance" << endl;
oss << statistics_string(out_weights,"\t") << endl;
return oss.str();
}
示例2: generate_vertex_copying_model
/*degree distribution of this model follows power law distribution.
* this is a most suitable synthetic model to real-world network like peer to peer networks and citation networks.*/
bool CDLib::generate_vertex_copying_model(graph& g, size_t num_nodes, size_t num_of_out_degree, size_t num_of_vertices_at_initial, double probability_to_copy_from_existing_vertex) {
if (num_of_vertices_at_initial > num_of_out_degree && probability_to_copy_from_existing_vertex >= 0 && probability_to_copy_from_existing_vertex <= 1) {
UniformRandomGeneratorAkash<wt_t> randdouble;
UniformRandomGeneratorAkash<id_type> randint;
init_empty_graph(g, num_nodes);
for (id_type i = 0; i < num_of_vertices_at_initial; i++) {
while (g.get_node_out_degree(i) < num_of_out_degree) {
back:
id_type R1 = randint.next(num_of_vertices_at_initial);
if (R1 == i)
goto back;
else {
g.add_edge(i, R1, 1);
}
}
}
for (id_type i = num_of_vertices_at_initial; i < num_nodes; i++) {
id_type R2 = randint.next(i);
vector<id_type> vertices_pointed_by_R2;
for (adjacent_edges_iterator aeit = g.out_edges_begin(R2); aeit != g.out_edges_end(R2); aeit++) {
vertices_pointed_by_R2.push_back(aeit->first);
}
while (g.get_node_out_degree(i) < num_of_out_degree) {
wt_t R3 = randdouble.next(1);
if (R3 < probability_to_copy_from_existing_vertex) {
g.add_edge(i, vertices_pointed_by_R2[g.get_node_out_degree(i)], 1);
} else {
A:
id_type R4 = randint.next(num_nodes);
if (R4 != i) {
g.add_edge(i, R4, 1);
} else
goto A;
}
}
}
g.set_graph_name("vc_" + T2str<size_t > (num_nodes) + "_" + T2str<size_t > (num_of_out_degree) + "_" + T2str<size_t > (num_of_vertices_at_initial) + "_" + T2str<double>(probability_to_copy_from_existing_vertex));
return 1;
} else {
// cout<<"\nnum_of_vertices_at_initial should greater than num_of_out_degree\n";
return 0;
}
}
示例3: generate_prices_model
void CDLib::generate_prices_model(graph& g, size_t num_nodes, size_t num_of_out_degree, size_t in_degree_constant) {
init_empty_graph(g, num_nodes);
vector<id_type> vertices_pointed_by_edges;
UniformRandomGeneratorAkash<id_type> randint;
UniformRandomGeneratorAkash<double> randdouble;
double probability = num_of_out_degree / (num_of_out_degree + in_degree_constant);
for (id_type i = 0; i < num_nodes; i++) {
while (g.get_node_out_degree(i) < num_of_out_degree) {
double R1 = randdouble.next(1);
if (R1 < probability) {
id_type R2 = randint.next(vertices_pointed_by_edges.size());
g.add_edge(i, vertices_pointed_by_edges[R2], 1);
vertices_pointed_by_edges.push_back(vertices_pointed_by_edges[R2]);
} else {
id_type R3 = randint.next(num_nodes);
g.add_edge(i, R3, 1);
vertices_pointed_by_edges.push_back(R3);
}
}
}
g.set_graph_name("price_" + T2str<size_t > (num_nodes) + "_" + T2str<size_t > (num_of_out_degree) + "_" + T2str<size_t > (in_degree_constant));
}