Class: DAG::Edge
- Inherits:
-
Object
- Object
- DAG::Edge
- Defined in:
- lib/zipf/dag.rb
Instance Attribute Summary collapse
-
#head ⇒ Object
Returns the value of attribute head.
-
#mark ⇒ Object
Returns the value of attribute mark.
-
#tail ⇒ Object
Returns the value of attribute tail.
-
#weight ⇒ Object
Returns the value of attribute weight.
Instance Method Summary collapse
-
#initialize(tail = nil, head = nil, weight = 0) ⇒ Edge
constructor
A new instance of Edge.
- #to_s ⇒ Object
Constructor Details
#initialize(tail = nil, head = nil, weight = 0) ⇒ Edge
Returns a new instance of Edge.
34 35 36 37 38 39 |
# File 'lib/zipf/dag.rb', line 34 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
#head ⇒ Object
Returns the value of attribute head.
32 33 34 |
# File 'lib/zipf/dag.rb', line 32 def head @head end |
#mark ⇒ Object
Returns the value of attribute mark.
32 33 34 |
# File 'lib/zipf/dag.rb', line 32 def mark @mark end |
#tail ⇒ Object
Returns the value of attribute tail.
32 33 34 |
# File 'lib/zipf/dag.rb', line 32 def tail @tail end |
#weight ⇒ Object
Returns the value of attribute weight.
32 33 34 |
# File 'lib/zipf/dag.rb', line 32 def weight @weight end |
Instance Method Details
#to_s ⇒ Object
41 42 43 44 45 46 |
# File 'lib/zipf/dag.rb', line 41 def to_s s = "DAG::Edge<#{@tail} ->[#{weight}] #{@head}" s += " x" if @mark s += ">" s end |