Class: DAG::Node
- Inherits:
-
Object
- Object
- DAG::Node
- Defined in:
- lib/zipf/dag.rb
Instance Attribute Summary collapse
-
#incoming ⇒ Object
Returns the value of attribute incoming.
-
#label ⇒ Object
Returns the value of attribute label.
-
#mark ⇒ Object
Returns the value of attribute mark.
-
#outgoing ⇒ Object
Returns the value of attribute outgoing.
-
#score ⇒ Object
Returns the value of attribute score.
Instance Method Summary collapse
- #add_edge(head, weight = 0) ⇒ Object
-
#initialize(label = nil, outgoing = [], incoming = [], score = nil) ⇒ Node
constructor
A new instance of Node.
- #repr ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(label = nil, outgoing = [], incoming = [], score = nil) ⇒ Node
Returns a new instance of Node.
9 10 11 12 13 14 |
# File 'lib/zipf/dag.rb', line 9 def initialize label=nil, outgoing=[], incoming=[], score=nil @label = label @outgoing = outgoing @incoming = incoming @score = nil end |
Instance Attribute Details
#incoming ⇒ Object
Returns the value of attribute incoming.
7 8 9 |
# File 'lib/zipf/dag.rb', line 7 def incoming @incoming end |
#label ⇒ Object
Returns the value of attribute label.
7 8 9 |
# File 'lib/zipf/dag.rb', line 7 def label @label end |
#mark ⇒ Object
Returns the value of attribute mark.
7 8 9 |
# File 'lib/zipf/dag.rb', line 7 def mark @mark end |
#outgoing ⇒ Object
Returns the value of attribute outgoing.
7 8 9 |
# File 'lib/zipf/dag.rb', line 7 def outgoing @outgoing end |
#score ⇒ Object
Returns the value of attribute score.
7 8 9 |
# File 'lib/zipf/dag.rb', line 7 def score @score end |
Instance Method Details
#add_edge(head, weight = 0) ⇒ Object
16 17 18 19 20 |
# File 'lib/zipf/dag.rb', line 16 def add_edge head, weight=0 exit if self==head # no self-cycles! @outgoing << DAG::Edge.new(self, head, weight) return @outgoing.last end |
#repr ⇒ Object
26 27 28 |
# File 'lib/zipf/dag.rb', line 26 def repr "#{to_s} #{@score} out:#{@outgoing} in:[#{@incoming.map{|e| e.to_s}.join ', '}]" end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/zipf/dag.rb', line 22 def to_s "DAG::Node<label:#{label}, outgoing:#{outgoing.size}, incoming:#{incoming.size}>" end |