本文整理汇总了C++中graph::get_node_in_degree方法的典型用法代码示例。如果您正苦于以下问题:C++ graph::get_node_in_degree方法的具体用法?C++ graph::get_node_in_degree怎么用?C++ graph::get_node_in_degree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graph
的用法示例。
在下文中一共展示了graph::get_node_in_degree方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_barabasi_albert_model
void CDLib::generate_barabasi_albert_model(graph& g, size_t num_nodes, size_t min_degree_of_node) {
init_empty_graph(g, num_nodes);
vector<id_type> vertices_with_edges;
UniformRandomGeneratorAkash<id_type> randint;
UniformRandomGeneratorAkash<double> randdouble;
for (id_type k = 1; k <= min_degree_of_node; k++) {
g.add_edge(0, k, 1);
vertices_with_edges.push_back(k);
}
for (id_type i = 1; i < num_nodes; i++) {
while (g.get_node_in_degree(i) < min_degree_of_node) {
double R1 = randdouble.next(1);
if (R1 < 0.5) {
id_type R2 = randint.next(vertices_with_edges.size());
g.add_edge(i, vertices_with_edges[R2], 1);
vertices_with_edges.push_back(vertices_with_edges[R2]);
} else {
id_type R3 = randint.next(i);
g.add_edge(i, R3, 1);
vertices_with_edges.push_back(R3);
}
}
}
g.set_graph_name("ba_" + T2str<size_t > (num_nodes) + "_" + T2str<size_t > (min_degree_of_node));
}