Class: DAG::Edge

Inherits:
Object
  • Object
show all
Defined in:
lib/zipf/dag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tail = nil, head = nil, weight = 0) ⇒ Edge

Returns a new instance of Edge.



33
34
35
36
37
38
# File 'lib/zipf/dag.rb', line 33

def initialize tail=nil, head=nil, weight=0
  @tail   = tail
  @head   = head
  @weight = weight
  @mark   = false # did we already follow this edge? -- for topological sorting
end

Instance Attribute Details

#headObject

Returns the value of attribute head.



31
32
33
# File 'lib/zipf/dag.rb', line 31

def head
  @head
end

#markObject

Returns the value of attribute mark.



31
32
33
# File 'lib/zipf/dag.rb', line 31

def mark
  @mark
end

#tailObject

Returns the value of attribute tail.



31
32
33
# File 'lib/zipf/dag.rb', line 31

def tail
  @tail
end

#weightObject

Returns the value of attribute weight.



31
32
33
# File 'lib/zipf/dag.rb', line 31

def weight
  @weight
end

Instance Method Details

#to_sObject



40
41
42
43
44
45
# File 'lib/zipf/dag.rb', line 40

def to_s
  s = "DAG::Edge<#{@tail} ->[#{weight}] #{@head}"
  s += " x" if @mark
  s += ">"
  s
end