Class: Pregel::Vertex

Inherits:
Object
  • Object
show all
Defined in:
lib/pregel/vertex.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, value, *outedges) ⇒ Vertex

Returns a new instance of Vertex.



6
7
8
9
10
11
12
13
# File 'lib/pregel/vertex.rb', line 6

def initialize(id, value, *outedges)
  @id = id
  @value = value
  @outedges = outedges
  @messages = []
  @active = true
  @superstep = 0
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/pregel/vertex.rb', line 3

def id
  @id
end

#messagesObject

Returns the value of attribute messages.



4
5
6
# File 'lib/pregel/vertex.rb', line 4

def messages
  @messages
end

#valueObject

Returns the value of attribute value.



4
5
6
# File 'lib/pregel/vertex.rb', line 4

def value
  @value
end

Instance Method Details

#active!Object



33
# File 'lib/pregel/vertex.rb', line 33

def active!;  @active = true;   end

#active?Boolean

Returns:

  • (Boolean)


34
# File 'lib/pregel/vertex.rb', line 34

def active?;  @active;          end

#computeObject



39
# File 'lib/pregel/vertex.rb', line 39

def compute; end

#deliver(to, msg) ⇒ Object



23
24
25
# File 'lib/pregel/vertex.rb', line 23

def deliver(to, msg)
  PostOffice.instance.deliver(to, msg)
end

#deliver_to_all_neighbors(msg) ⇒ Object



19
20
21
# File 'lib/pregel/vertex.rb', line 19

def deliver_to_all_neighbors(msg)
  edges.each {|e| deliver(e, msg)}
end

#edgesObject



15
16
17
# File 'lib/pregel/vertex.rb', line 15

def edges
  block_given? ? @outedges.each {|e| yield e} : @outedges
end

#haltObject



32
# File 'lib/pregel/vertex.rb', line 32

def halt;     @active = false;  end

#neighborsObject



37
# File 'lib/pregel/vertex.rb', line 37

def neighbors; @outedges; end

#stepObject



27
28
29
30
# File 'lib/pregel/vertex.rb', line 27

def step
  @superstep += 1
  compute
end

#superstepObject



36
# File 'lib/pregel/vertex.rb', line 36

def superstep; @superstep; end