Class: RubyGraphWalker::Vertex
- Inherits:
-
Object
- Object
- RubyGraphWalker::Vertex
- Defined in:
- lib/graph.rb
Instance Attribute Summary collapse
-
#edges ⇒ Object
Returns the value of attribute edges.
-
#name ⇒ Object
Returns the value of attribute name.
-
#trait ⇒ Object
Returns the value of attribute trait.
-
#visited ⇒ Object
Returns the value of attribute visited.
-
#weight ⇒ Object
Returns the value of attribute weight.
-
#zindex ⇒ Object
Returns the value of attribute zindex.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Vertex
constructor
A new instance of Vertex.
Constructor Details
#initialize(args = {}) ⇒ Vertex
Returns a new instance of Vertex.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/graph.rb', line 7 def initialize(args = {}) [:name, :edges, :trait].each { |key| raise "#{key} is not defined for Vertex #{args}" unless args[key] } @name = args[:name] @weight = args[:weight] || 1 @trait = args[:trait] @visited = args[:visited] || false @weight = args[:zindex] || 0 @edges = [] args[:edges].each do |edge| e = Edge.new(edge) e.from = @name e.to = edge[:to] add_edge(e) end end |
Instance Attribute Details
#edges ⇒ Object
Returns the value of attribute edges.
6 7 8 |
# File 'lib/graph.rb', line 6 def edges @edges end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/graph.rb', line 6 def name @name end |
#trait ⇒ Object
Returns the value of attribute trait.
6 7 8 |
# File 'lib/graph.rb', line 6 def trait @trait end |
#visited ⇒ Object
Returns the value of attribute visited.
6 7 8 |
# File 'lib/graph.rb', line 6 def visited @visited end |
#weight ⇒ Object
Returns the value of attribute weight.
6 7 8 |
# File 'lib/graph.rb', line 6 def weight @weight end |
#zindex ⇒ Object
Returns the value of attribute zindex.
6 7 8 |
# File 'lib/graph.rb', line 6 def zindex @zindex end |