Class: Graph
- Inherits:
-
Object
- Object
- Graph
- Defined in:
- lib/MinimumSpanningTree.rb
Instance Attribute Summary collapse
-
#edges ⇒ Object
readonly
Returns the value of attribute edges.
-
#num_vertices ⇒ Object
readonly
Returns the value of attribute num_vertices.
Instance Method Summary collapse
- #add_edge(u, v, weight) ⇒ Object
-
#initialize(num_vertices) ⇒ Graph
constructor
A new instance of Graph.
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
#edges ⇒ Object (readonly)
Returns the value of attribute edges.
53 54 55 |
# File 'lib/MinimumSpanningTree.rb', line 53 def edges @edges end |
#num_vertices ⇒ Object (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 |