当前位置: 首页>>代码示例>>C++>>正文


C++ graph::get_node_in_degree方法代码示例

本文整理汇总了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();
}
开发者ID:BalkiLab,项目名称:graffy,代码行数:31,代码来源:graph_summary.cpp

示例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));
}
开发者ID:BalkiLab,项目名称:graffy,代码行数:27,代码来源:random_graph.cpp


注:本文中的graph::get_node_in_degree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。