mirror of https://gitee.com/bigwinds/arangodb
parent
93a03c923a
commit
27098e9e4f
|
@ -45,21 +45,19 @@ struct PRComputation : public VertexComputation<float, float, float> {
|
|||
PRComputation() {}
|
||||
void compute(MessageIterator<float> const& messages) override {
|
||||
float* ptr = mutableVertexData();
|
||||
//float copy = *ptr;
|
||||
float copy = *ptr;
|
||||
|
||||
//if (globalSuperstep() == 0) {
|
||||
// *ptr = 1.0 / context()->vertexCount();
|
||||
//} else {
|
||||
if (globalSuperstep() > 0) {
|
||||
if (globalSuperstep() == 0) {
|
||||
*ptr = 1.0 / context()->vertexCount();
|
||||
} else {
|
||||
float sum = 0.0;
|
||||
for (const float* msg : messages) {
|
||||
sum += *msg;
|
||||
}
|
||||
*ptr = 0.85 * sum + 0.15;
|
||||
}// / context()->vertexCount();
|
||||
//}
|
||||
//float diff = fabs(copy - *ptr);
|
||||
//aggregate<float>(kConvergence, diff);
|
||||
*ptr = 0.85 * sum + 0.15 / context()->vertexCount();
|
||||
}
|
||||
float diff = fabs(copy - *ptr);
|
||||
aggregate<float>(kConvergence, diff);
|
||||
|
||||
RangeIterator<Edge<float>> edges = getEdges();
|
||||
float val = *ptr / edges.size();
|
||||
|
@ -93,8 +91,8 @@ struct PRMasterContext : public MasterContext {
|
|||
};
|
||||
|
||||
bool postGlobalSuperstep() override {
|
||||
//float const* diff = getAggregatedValue<float>(kConvergence);
|
||||
return globalSuperstep() < 20;// || *diff > _threshold;
|
||||
float const* diff = getAggregatedValue<float>(kConvergence);
|
||||
return globalSuperstep() < 1 || *diff > _threshold;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ struct PageRank : public SimpleAlgorithm<float, float, float> {
|
|||
PageRank(arangodb::velocypack::Slice const& params);
|
||||
|
||||
GraphFormat<float, float>* inputFormat() const override {
|
||||
return new VertexGraphFormat<float, float>(_resultField, 1);
|
||||
return new VertexGraphFormat<float, float>(_resultField, 0);
|
||||
}
|
||||
|
||||
MessageFormat<float>* messageFormat() const override {
|
||||
|
|
Loading…
Reference in New Issue