Sha256: 0b6fac884a0816daa5c966d9c0d8b97427f3c356d2fc65cb2eae2ff2657741d1
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
require 'elaine/distributed' class DistributedTriadCensusVertex < Elaine::Distributed::Vertex def compute # puts "Working on supserstep: #{superstep}" if superstep == 1 deliver_to_all_neighbors({source: id; neighborhood: @outedges}) elsif superstep == 2 # sum = messages.inject(0) {|total,msg| total += msg; total } # sum = messages.reduce(0, :+) @value = {type2: 0, type3: 0 } u = id.to_s.plit("_")[1].to_i messages.each(0) do |msg| # raise "Got an out-of-step message! current superstep: #{superstep}, message from superstep: #{msg[:superstep]}" if msg[:superstep] != (superstep - 1) v = msg[:source].to_s.split("_")[1].to_i if u < v msg[:neighborhood].each do |node_w| w = node_w.to_s.split("_")[1].to_i if v < w num_edges = 2 if @outedges.include? node_w num_edges += 1 end @value[:type2] += 1 if num_edges == 2 @value[:type3] += 1 if num_edges == 3 end end end end else vote_to_stop end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
elaine-0.0.3 | spec/distributed_triad_census_vertex.rb |