Skip to content

Label Propagation

bholt edited this page Oct 2, 2014 · 1 revision

Rough off-the cuff pseudocode of it:

using label = long;

struct label_counter {
  map<label,int> counts;

  label_counter& operator+=(label_counter& x) {
    counts[label] += 1;
  }
}

using G = Graph<label,empty>;

struct LabelPropagation : public GraphlabVertexProgram<G,label_counter> {

  label other_label;

  label_counter gather(Vertex& src, Edge& e) const {
    return src->label;
  }

  void apply(Vertex& v, const Gather& total) {
    other_label = v->label;
  }

  label_counter scatter(Vertex& target) const {
    return label_counter(other_label, 1);
  }
}

Clone this wiki locally