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.
8 9 10 11 12 13 |
# File 'lib/zipf/dag.rb', line 8 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.
6 7 8 |
# File 'lib/zipf/dag.rb', line 6 def incoming @incoming end |
#label ⇒ Object
Returns the value of attribute label.
6 7 8 |
# File 'lib/zipf/dag.rb', line 6 def label @label end |
#mark ⇒ Object
Returns the value of attribute mark.
6 7 8 |
# File 'lib/zipf/dag.rb', line 6 def mark @mark end |
#outgoing ⇒ Object
Returns the value of attribute outgoing.
6 7 8 |
# File 'lib/zipf/dag.rb', line 6 def outgoing @outgoing end |
#score ⇒ Object
Returns the value of attribute score.
6 7 8 |
# File 'lib/zipf/dag.rb', line 6 def score @score end |
Instance Method Details
#add_edge(head, weight = 0) ⇒ Object
15 16 17 18 19 |
# File 'lib/zipf/dag.rb', line 15 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
25 26 27 |
# File 'lib/zipf/dag.rb', line 25 def repr "#{to_s} #{@score} out:#{@outgoing} in:[#{@incoming.map{|e| e.to_s}.join ', '}]" end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/zipf/dag.rb', line 21 def to_s "DAG::Node<label:#{label}, outgoing:#{outgoing.size}, incoming:#{incoming.size}>" end |