Class: Graph

Inherits:
Object
  • Object
show all
Defined in:
lib/MinimumSpanningTree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(num_vertices) ⇒ Graph

Returns a new instance of Graph.



55
56
57
58
# File 'lib/MinimumSpanningTree.rb', line 55

def initialize(num_vertices)
  @edges = []
  @num_vertices = num_vertices
end

Instance Attribute Details

#edgesObject (readonly)

Returns the value of attribute edges.



53
54
55
# File 'lib/MinimumSpanningTree.rb', line 53

def edges
  @edges
end

#num_verticesObject (readonly)

Returns the value of attribute num_vertices.



53
54
55
# File 'lib/MinimumSpanningTree.rb', line 53

def num_vertices
  @num_vertices
end

Instance Method Details

#add_edge(u, v, weight) ⇒ Object



60
61
62
# File 'lib/MinimumSpanningTree.rb', line 60

def add_edge(u, v, weight)
  @edges << [u, v, weight]
end