本文整理汇总了C++中graph_type::transform_vertices方法的典型用法代码示例。如果您正苦于以下问题:C++ graph_type::transform_vertices方法的具体用法?C++ graph_type::transform_vertices怎么用?C++ graph_type::transform_vertices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graph_type
的用法示例。
在下文中一共展示了graph_type::transform_vertices方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_aggregator
void test_aggregator(graphlab::distributed_control& dc,
graphlab::command_line_options& clopts,
graph_type& graph) {
std::cout << "Constructing an engine for all neighbors" << std::endl;
agg_engine_type engine(dc, graph, clopts);
engine.add_vertex_aggregator<size_t>("num_vertices_counter", agg_map, agg_finalize);
engine.add_edge_aggregator<size_t>("num_edges_counter", agg_edge_map, agg_edge_finalize);
// reset all
graph.transform_vertices(set_vertex_to_one);
graph.transform_edges(set_edge_to_one);
ASSERT_EQ(graph.map_reduce_vertices<size_t>(identity_vertex_map), graph.num_vertices());
graph.transform_vertices(vertex_plus_one);
ASSERT_EQ(graph.map_reduce_vertices<size_t>(identity_vertex_map), 2 * graph.num_vertices());
engine.transform_vertices(vertex_minus_one_context);
ASSERT_EQ(graph.map_reduce_vertices<size_t>(identity_vertex_map), graph.num_vertices());
ASSERT_EQ(engine.map_reduce_vertices<size_t>(identity_vertex_map_context), graph.num_vertices());
ASSERT_EQ(graph.map_reduce_edges<size_t>(identity_edge_map), graph.num_edges());
graph.transform_edges(edge_plus_one);
ASSERT_EQ(graph.map_reduce_edges<size_t>(identity_edge_map), 2 * graph.num_edges());
engine.transform_edges(edge_minus_one_context);
ASSERT_EQ(graph.map_reduce_edges<size_t>(identity_edge_map), graph.num_edges());
ASSERT_EQ(engine.map_reduce_edges<size_t>(identity_edge_map_context), graph.num_edges());
ASSERT_TRUE(engine.aggregate_now("num_vertices_counter"));
ASSERT_TRUE(engine.aggregate_now("num_edges_counter"));
ASSERT_TRUE(engine.aggregate_periodic("num_vertices_counter", 0.2));
ASSERT_TRUE(engine.aggregate_periodic("num_edges_counter", 0.2));
std::cout << "Scheduling all vertices to count their neighbors" << std::endl;
engine.signal_all(100);
std::cout << "Running!" << std::endl;
engine.start();
std::cout << "Finished" << std::endl;
}