| 查看: 2427 | 回复: 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); } } |
» 猜你喜欢
影响面上的因素
已经有6人回复
一个有机合成实验室都需要哪些设备?
已经有11人回复
求各位大神看下
已经有23人回复
面上再次挂了,太难了,躺也躺不了,倦也卷不过,小学校之殇!
已经有30人回复
2027年申博
已经有4人回复
好消息?这个有何含义???
已经有10人回复
咨询面上基金
已经有4人回复
8月时间戳变的,举个手。玩一下,释放压力
已经有10人回复
【2027博士申请】纳米药物递送方向
已经有4人回复
UV压敏胶开发
已经有7人回复











回复此楼