本文整理汇总了C++中graph_type::vertex_type类的典型用法代码示例。如果您正苦于以下问题:C++ vertex_type类的具体用法?C++ vertex_type怎么用?C++ vertex_type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vertex_type类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: save_vertex
std::string save_vertex(const graph_type::vertex_type& v) {
std::stringstream sstream;
if (is_user(v)) {
const std::vector<std::pair<double, graphlab::vertex_id_type> >& top_rated
= v.data().top_rated;
const std::vector<std::pair<double, graphlab::vertex_id_type> >& top_pred
= v.data().top_pred;
if (top_rated.size() < 10 || top_pred.size() == 0) {
return "";
}
// save top rated
sstream << v.id() << " ";
sstream << pair2str(top_rated[0]);
for (size_t i = 1; i < top_rated.size(); ++i) {
sstream << "," << (pair2str(top_rated[i]));
}
// save top pred
sstream << " ";
sstream << pair2str(top_pred[0]);
for (size_t i = 1; i < top_pred.size(); ++i) {
sstream << "," << (pair2str(top_pred[i]));
}
sstream << "\n";
return sstream.str();
} else {
return "";
}
}
开发者ID:LiuJianan,项目名称:powerswitch,代码行数:28,代码来源:collect_result.hpp
示例2: transform_ortho
void transform_ortho(graph_type::vertex_type & vertex){
assert(curMat != NULL && curMat->start_offset < pcurrent->offset);
for (int i=curMat->start_offset; i< pcurrent->offset; i++){
//assert(alphas.pvec[i-curMat->start_offset] != 0);
vertex.data().pvec[pcurrent->offset] -= alphas.pvec[i-curMat->start_offset] * vertex.data().pvec[i];
}
}
开发者ID:Alienfeel,项目名称:graphlab,代码行数:7,代码来源:math.hpp
示例3: save_vertex
std::string save_vertex(const graph_type::vertex_type& vtx)
{
std::stringstream strm;
strm << vtx.id() << "\t" << vtx.data().dist << "\n";
if (vtx.data().dist == std::numeric_limits<distance_type>::max())
return "";
else
return strm.str();
}
开发者ID:ddmbr,项目名称:pregelplus-code,代码行数:9,代码来源:SSSP.cpp
示例4: output_vector
gather_type output_vector(const graph_type::vertex_type & vertex){
assert(pcurrent && pcurrent->offset >= 0 && pcurrent->offset < vertex.data().pvec.size());
gather_type ret;
assert(pcurrent->end - pcurrent->start > 0);
assert(vertex.id() - pcurrent->start >= 0);
ret.pvec = vec::Zero(pcurrent->end - pcurrent->start);
ret.pvec[vertex.id() - pcurrent->start] = vertex.data().pvec[pcurrent->offset];
return ret;
}
开发者ID:Alienfeel,项目名称:graphlab,代码行数:9,代码来源:math.hpp
示例5: collect_map
map_join_pair collect_map (const graph_type::vertex_type& center,
graph_type::edge_type& edge,
const graph_type::vertex_type& other) {
map_join_pair ret;
if (edge.data().role == edge_data::TRAIN) {
ret.first.data[other.id()] = edge.data().obs; // save the old rating
} else {
// use prediction
double pred = center.data().factor.dot(other.data().factor);
ret.second.data[other.id()] = pred; // save the prediction
}
return ret;
}
开发者ID:LiuJianan,项目名称:powerswitch,代码行数:13,代码来源:collect_result.hpp
示例6: map_reduce_ortho
gather_type map_reduce_ortho(const graph_type::vertex_type & vertex){
gather_type ret;
assert(curoffset >= 0);
assert(curMat && curMat->start_offset - pcurrent->offset);
ret.pvec = vec::Zero(curoffset);
assert(curMat != NULL && curMat->start_offset < pcurrent->offset);
//for (int i=mat.start_offset; i< current.offset; i++){
for (int i=curMat->start_offset; i< pcurrent->offset; i++){
ret.pvec[i - curMat->start_offset] = vertex.data().pvec[i] * vertex.data().pvec[pcurrent->offset];
}
//printf("map_Reduce_ortho: node %d\n", vertex.id());
//std::cout<<ret.pvec<<std::endl;
return ret;
}
开发者ID:Alienfeel,项目名称:graphlab,代码行数:14,代码来源:math.hpp
示例7: collect_function
void collect_function (engine_type::context_type& context,
graph_type::vertex_type& vertex) {
if (is_user(vertex)) {
map_join_pair sum = context.map_reduce<map_join_pair>(COLLECT_TASK, ALL_EDGES);
vertex.data().top_rated = sum.first.get_top_k(10);
vertex.data().top_pred = sum.second.get_top_k(5);
}
}
开发者ID:LiuJianan,项目名称:powerswitch,代码行数:8,代码来源:collect_result.hpp
示例8: save_vertex
std::string save_vertex(graph_type::vertex_type v)
{
stringstream strm;
//strm << "Process id: " << dc.procid() << " : " << mpi_tools::rank() << " / " << mpi_tools::size() << "\n";
/*char name[81];
gethostname(name, 80);
name[80] = 0;*/
if( v.data().in_core ) {
return string("1\n");
}
else {
return string();
}
}
开发者ID:todayman,项目名称:cs423_graphlab,代码行数:14,代码来源:kcore.cpp
示例9: get_topk
/*
* \brief
* Aggregates in parallel the list of items rated by each user by map reducing on all the user
* vertices connected to an item. It also counts the number of users common between the current item
* and the items in the aggregated list. It then removes the item that have less than MIN_ALLOWED_INTERSECTION
* common users.
*/
void get_topk(engine_type::context& context, graph_type::vertex_type vertex)
{
// Gather the list of items rated by each user.
rated_type gather_result = graphlab::warp::map_reduce_neighborhood<rated_type, graph_type::vertex_type>(vertex, graphlab::IN_EDGES, map_get_topk, combine);
// Get a reference to the vertex data
vertex_data& vdata = vertex.data();
// Store the list of similar items into the recommended items
vdata.recommended_items = gather_result;
// TODO: Trim the result to have only topk entries using a heap
// Increment the num_updates to the vertex by 1
vdata.num_updates++;
}
开发者ID:ameyavilankar,项目名称:graphlab,代码行数:23,代码来源:temp.cpp
示例10: map_get_topk
/*
* \brief Returns the sparse vector containing all the items rated by the user vertex.
*/
rated_type map_get_topk(graph_type::edge_type edge, graph_type::vertex_type other)
{
// return the list of items rated by the user
const rated_type& similar_items = other.data().rated_items;
// To hold the similarity score
rated_type similarity_score;
// Get the id of the current item
id_type current_id = get_other_vertex(edge, other).id();
// Go through all the items rated by the other user, except for current item
for(rated_type::const_iterator cit = similar_items.begin(); cit != similar_items.end(); cit++)
if(cit->first != current_id)
{
// Get the score and add only if score is valid
// Score is invalid if common users are less than MIN_ALLOWED_INTERSECTION
double score = adj_cosine_similarity(item_vector[cit->first], item_vector[current_id]);
if(score != INVALID_SIMILARITY)
similarity_score[cit->first] = score;
}
return similarity_score;
}
开发者ID:ameyavilankar,项目名称:graphlab,代码行数:27,代码来源:temp.cpp
示例11: map_rank
double map_rank(const graph_type::vertex_type& v) { return v.data().pagerank; }
开发者ID:pkuwalter,项目名称:evaluation,代码行数:1,代码来源:PageRank.cpp
示例12: pagerank_sum
double pagerank_sum(graph_type::vertex_type v) {
return v.data();
}
开发者ID:YosubShin,项目名称:PowerGraph,代码行数:3,代码来源:pagerank.cpp
示例13: init_vertex
/*
* A simple function used by graph.transform_vertices(init_vertex);
* to initialize the vertes data.
*/
void init_vertex(graph_type::vertex_type& vertex) { vertex.data() = 1; }
开发者ID:YosubShin,项目名称:PowerGraph,代码行数:5,代码来源:pagerank.cpp
示例14: select_in_range
bool select_in_range(const graph_type::vertex_type & vertex){
return vertex.id() >= (uint)pcurrent->start && vertex.id() < (uint)pcurrent->end;
}
开发者ID:Alienfeel,项目名称:graphlab,代码行数:3,代码来源:math.hpp
示例15: save_vertex
std::string save_vertex(graph_type::vertex_type v) {
std::stringstream strm;
strm << v.id() << "\t" << v.data() << "\n";
return strm.str();
}
开发者ID:YosubShin,项目名称:PowerGraph,代码行数:5,代码来源:pagerank.cpp
示例16: calc_norm
gather_type calc_norm(const graph_type::vertex_type & vertex){
gather_type ret;
assert(pcurrent && pcurrent->offset < vertex.data().pvec.size());
ret.training_rmse = pow(vertex.data().pvec[pcurrent->offset], 2);
return ret;
}
开发者ID:Alienfeel,项目名称:graphlab,代码行数:6,代码来源:math.hpp
示例17: init_vertex
void init_vertex(graph_type::vertex_type& vertex)
{
vertex.data().dist = std::numeric_limits<distance_type>::max();
}
开发者ID:ddmbr,项目名称:pregelplus-code,代码行数:5,代码来源:SSSP.cpp
示例18: floatMaxAggregator
float_max floatMaxAggregator(pagerank::icontext_type& context, const graph_type::vertex_type& vertex) {
return float_max(vertex.data());
}
开发者ID:neozhangthe1,项目名称:saedb,代码行数:3,代码来源:pagerank.cpp
示例19: save_vertex
std::string save_vertex(graph_type::vertex_type v) {
std::stringstream strm;
strm << v.id() << "\t" << std::fixed << std::setprecision(17) << v.data() << "\n";
return strm.str();
}
开发者ID:xvz,项目名称:giraphuc,代码行数:5,代码来源:pagerank.cpp
示例20: assign_vec
void assign_vec(graph_type::vertex_type & vertex){
if (!info.is_square())
assert(vertex.id() - pcurrent->start >= 0 && vertex.id() - pcurrent->start < curvec.size());
vertex.data().pvec[pcurrent->offset] = curvec[vertex.id() - pcurrent->start];
}
开发者ID:Alienfeel,项目名称:graphlab,代码行数:5,代码来源:math.hpp
注:本文中的graph_type::vertex_type类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论