如果有人知道 Graphchi 并试图理解 communitydetection.cpp 代码,我需要帮助来理解这段代码在一步一步地做什么:
for(int i=0; i < vertex.num_edges(); i++) {
bidirectional_label edgelabel = vertex.edge(i)->get_data();
vid_t nblabel = neighbor_label(edgelabel, vertex.id(), vertex.edge(i)->vertex_id());
std::map<vid_t, int>::iterator existing = counts.find(nblabel);
int newcount = 0;
if(existing == counts.end()) {
counts.insert(std::pair<vid_t,int>(nblabel, 1));
newcount = 1;
} else {
existing->second++;//map iterator
newcount = existing->second;
}
if (newcount > maxcount || (maxcount == newcount && nblabel > maxlabel)) {
maxlabel = nblabel;
maxcount = newcount;
}
}
newlabel = maxlabel;
}