Class: Bio::Velvet::Underground::Graph::NodeArray

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/bio-velvet_underground/graph.rb

Instance Method Summary collapse

Constructor Details

#initialize(graph) ⇒ NodeArray

Returns a new instance of NodeArray.



52
53
54
# File 'lib/bio-velvet_underground/graph.rb', line 52

def initialize(graph)
  @graph = graph
end

Instance Method Details

#[](node_id) ⇒ Object



66
67
68
69
70
71
# File 'lib/bio-velvet_underground/graph.rb', line 66

def [](node_id)
  return nil if node_id < 1 or node_id > @graph.internal_graph_struct[:nodeCount]
  pointer = Bio::Velvet::Underground.getNodeInGraph @graph.internal_graph_struct, node_id
  node_struct = Bio::Velvet::Underground::NodeStruct.new pointer
  Node.new(@graph, node_struct)
end

#eachObject



56
57
58
59
60
# File 'lib/bio-velvet_underground/graph.rb', line 56

def each
  (1..length).each do |node_id|
    yield self[node_id]
  end
end

#lengthObject



62
63
64
# File 'lib/bio-velvet_underground/graph.rb', line 62

def length
  Bio::Velvet::Underground.nodeCount @graph.internal_graph_struct
end