本文整理汇总了C++中graphchi_context::log_change方法的典型用法代码示例。如果您正苦于以下问题:C++ graphchi_context::log_change方法的具体用法?C++ graphchi_context::log_change怎么用?C++ graphchi_context::log_change使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graphchi_context
的用法示例。
在下文中一共展示了graphchi_context::log_change方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
/**
* Pagerank update function.
*/
void update(graphchi_vertex<VertexDataType, EdgeDataType> &v, graphchi_context &ginfo) {
float sum=0;
if (ginfo.iteration == 0) {
/* On first iteration, initialize vertex and out-edges.
The initialization is important,
because on every run, GraphChi will modify the data in the edges on disk.
*/
update_edge_data(v, 1.0);
v.set_data(RANDOMRESETPROB);
} else {
/* Compute the sum of neighbors' weighted pageranks by
reading from the in-edges. */
for(int i=0; i < v.num_inedges(); i++) {
//float val = v.inedge(i)->get_data();
//sum += val;
struct weightE eData = v.inedge(i)->get_data();
sum += eData.pagerank;
}
/* Compute my pagerank */
float pagerank = RANDOMRESETPROB + (1 - RANDOMRESETPROB) * sum;
/* Write my pagerank divided by the number of out-edges to
each of my out-edges. */
update_edge_data(v, pagerank);
/* Keep track of the progression of the computation.
GraphChi engine writes a file filename.deltalog. */
ginfo.log_change(std::abs(pagerank - v.get_data()));
/* Set my new pagerank as the vertex value */
v.set_data(pagerank);
}
}
示例2: update
/**
* Pagerank update function.
*/
void update(graphchi_vertex<VertexDataType, EdgeDataType> &v, graphchi_context &ginfo) {
float sum=0;
float prv = 0.0;
float pagerankcont = 0.0;
if (ginfo.iteration == 0) {
/* On first iteration, initialize vertex and out-edges.
The initialization is important,
because on every run, GraphChi will modify the data in the edges on disk.
*/
/* For the weighted version */
update_edge_data(v, 1.0, true);
v.set_data(RANDOMRESETPROB);
//v.set_data(1.0);
} else {
/* We need to come up with the weighted version */
for(int i=0; i < v.num_inedges(); i++) {
chivector<float> * evector = v.inedge(i)->get_vector();
assert(evector->size() >= 2);
sum += evector->get(1);
//std::cout << v.id() << " with data: " << evector->get(1) << " with weight " << evector->get(0) << std::endl;
//std::cout << v.id() << " edge endpoint: " << v.inedge(i)->vertex_id() << std::endl;
//evector->clear();
}
/* Compute my pagerank */
prv = RANDOMRESETPROB + (1 - RANDOMRESETPROB) * sum;
//std::cout << "sum" << sum << "pagerank: " << prv << std::endl;
update_edge_data(v, prv, false);
/* Keep track of the progression of the computation.
GraphChi engine writes a file filename.deltalog. */
double delta = std::abs(prv - v.get_data());
//std::cout << "pagerank: " << prv << "v.data" << v.get_data() << "delta: " << delta << std::endl;
ginfo.log_change(delta);
/* Set my new pagerank as the vertex value */
v.set_data(prv);
}
}