edge_dir_type gather_edges(icontext_type& context, const vertex_type& vertex) const { if (context.iteration() == 0) { return graphlab::ALL_EDGES; } else { return graphlab::NO_EDGES; } }
edge_dir_type scatter_edges(icontext_type& context, const vertex_type& vertex) const { if (context.iteration() < ROUND) return graphlab::OUT_EDGES; else return graphlab::NO_EDGES; }
void apply(icontext_type& context, vertex_type& vertex, const graphlab::empty& empty) { if (context.iteration() < ROUND) { context.signal(vertex); } if(context.iteration() == 0) { return; } pagerank_type new_pagerank = 0.15 + 0.85 * sum_pagerank; vertex.data().pagerank = new_pagerank; }
gather_type gather(icontext_type& context, const vertex_type& vertex, edge_type& edge) const { if (context.iteration() == 0) { if (vertex.id() == edge.source().id()) { return gather_type(edge.target().id()); } else { return gather_type(edge.source().id()); } } else { return gather_type(); } }
void apply(icontext_type& context, vertex_type& vertex, const gather_type &total) { if (context.iteration() == 0) { vertex.data().neighbors = total.get(); } else { size_t d = vertex.data().neighbors.size(); size_t t = last_msg; // Due to rounding errors, the results is sometimes not exactly // 0.0 even when it should be. Explicitly set LCC to 0 if that // is the case, other calculate it as tri / (degree * (degree - 1)) double lcc = (d < 2 || t == 0) ? 0.0 : double(t) / (d * (d - 1)); vertex.data().clustering_coef = lcc; } }
void scatter(icontext_type& context, const vertex_type& vertex, edge_type& edge) const { if (context.iteration() == 0) { pair<size_t, size_t> p = count_triangles(edge.source(), edge.target()); if (p.first > 0) { context.signal(edge.source(), p.first); } if (p.second > 0) { context.signal(edge.target(), p.second); } } else { // } }
/** * \brief If the distance is smaller then update */ void apply(icontext_type& context, vertex_type& vertex, const gather_type& total) { changed = false; if(context.iteration() == 0) { changed = true; vertex.data().dist = 0; context.setUpdateFlag(changed); return; //lastchange = vertex.data().dist; } if(vertex.data().dist > total.dist) { changed = true; vertex.data().dist = total.dist; //lastchange = vertex.data().dist; } context.setUpdateFlag(changed); //std::cout << "vid=" << vertex.id() << ", val=" << vertex.data().dist << "\n"; }