| 查看: 2367 | 回复: 0 | ||
[求助]
PageRank算法代码
|
|
谁能帮我讲讲下面这段PageRank算法代码啊,跪求啊。 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. */ for(int i=0; i < v.num_outedges(); i++) { graphchi_edge<float> * edge = v.outedge(i); edge->set_data(1.0 / v.num_outedges()); } 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; } /* 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. */ if (v.num_outedges() > 0) { float pagerankcont = pagerank / v.num_outedges(); for(int i=0; i < v.num_outedges(); i++) { graphchi_edge<float> * edge = v.outedge(i); edge->set_data(pagerankcont); } } /* 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); } } |
» 猜你喜欢
售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急
已经有3人回复
售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急
已经有3人回复
售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急
已经有3人回复
售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急
已经有3人回复
基金正文30页指的是报告正文还是整个申请书
已经有4人回复
今年春晚有几个节目很不错,点赞!
已经有6人回复
球磨粉体时遇到了大的问题,请指教!
已经有15人回复
过年走亲戚时感受到了所开私家车的鄙视链
已经有5人回复
情人节自我反思:在爱情中有过遗憾吗?
已经有5人回复
江汉大学解明教授课题组招博士研究生/博士后
已经有3人回复














回复此楼