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


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

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

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

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


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