本文整理汇总了C++中sgraph::get_num_partitions方法的典型用法代码示例。如果您正苦于以下问题:C++ sgraph::get_num_partitions方法的具体用法?C++ sgraph::get_num_partitions怎么用?C++ sgraph::get_num_partitions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sgraph
的用法示例。
在下文中一共展示了sgraph::get_num_partitions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ret
std::vector<std::vector<T>> create_vertex_data_from_const(const sgraph& g, const T& init) {
std::vector<std::vector<T>> ret(g.get_num_partitions());
for (size_t i = 0; i < g.get_num_partitions(); ++i) {
ret[i] = std::vector<T>(g.vertex_partition(i).size(), init);
}
return ret;
}
示例2: ret
std::vector<std::shared_ptr<sarray<flexible_type>>>
vertex_apply(sgraph& g,
flex_type_enum result_type,
Fn fn) {
std::vector<std::shared_ptr<sarray<flexible_type>>> ret(g.get_num_partitions());
// get all the vertex partitions.
const std::vector<sframe>& vdata = g.vertex_group();
parallel_for((size_t)(0), (size_t)g.get_num_partitions(), [&](size_t i) {
std::shared_ptr<sarray<flexible_type>> ret_partition = std::make_shared<sarray<flexible_type>>();
ret_partition->open_for_write(1);
ret_partition->set_type(result_type);
transform(vdata[i], *ret_partition, fn);
ret_partition->close();
ret[i] = ret_partition;
});
return ret;
}
示例3: vertex_reduce
ResultType vertex_reduce(sgraph& g,
std::string column_name,
Reducer fn,
Combiner combine,
ResultType init = ResultType()) {
const std::vector<sframe>& vdata = g.vertex_group();
mutex lock;
ResultType ret = init;
parallel_for((size_t)(0), (size_t)g.get_num_partitions(), [&](size_t i) {
std::shared_ptr<sarray<flexible_type>> graph_field = vdata[i].select_column(column_name);
std::vector<ResultType> result =
graphlab::reduce(*graph_field,
[&](const flexible_type& left, ResultType& right) {
fn(left, right);
return true;
}, init);
std::unique_lock<mutex> result_lock(lock);
for (ResultType& res: result) {
combine(res, ret);
}
});
return ret;
}
示例4: ResultType
typename std::enable_if<!std::is_convertible<Reducer, std::string>::value, ResultType>::type
/*ResultType*/ vertex_reduce(sgraph& g,
Reducer fn,
Combiner combine,
ResultType init = ResultType()) {
const std::vector<sframe>& vdata = g.vertex_group();
mutex lock;
ResultType ret = init;
parallel_for((size_t)(0), (size_t)g.get_num_partitions(), [&](size_t i) {
std::vector<ResultType> result =
graphlab::reduce(vdata[i],
[&](const std::vector<flexible_type>& left, ResultType& right) {
fn(left, right);
return true;
}, init);
std::unique_lock<mutex> result_lock(lock);
for (ResultType& res: result) {
combine(res, ret);
}
});
return ret;
}