Esempio n. 1
0
func (j *MVJob) Write(g *waffle.Graph) error {
	m := -1
	for _, v := range g.Vertices() {
		v := v.(*MVVertex)
		if v.Max > m {
			m = v.Max
		}
	}
	log.Printf("max is %d", m)
	return nil
}
Esempio n. 2
0
func (v *MVVertex) Compute(g *waffle.Graph, msgs []waffle.Message) {
	max := 0
	for _, msg := range msgs {
		val := msg.(*MVMessage).Value
		if val > max {
			max = val
		}
	}
	if v.Value > max {
		max = v.Value
	}
	if max > v.Max {
		v.Max = max
		for _, e := range g.Edges(v.Id()) {
			g.SendMessage(&MVMessage{Value: v.Max, Dest: e.Destination()})
		}
	}
	v.Vactive = false
}