Class: MOSAIK::Graph::Cluster
- Inherits:
-
Object
- Object
- MOSAIK::Graph::Cluster
- Extended by:
- T::Sig
- Defined in:
- lib/mosaik/graph/cluster.rb
Overview
Cluster of vertices
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#vertices ⇒ Object
readonly
Returns the value of attribute vertices.
Instance Method Summary collapse
- #add_vertex(vertex) ⇒ Object
-
#initialize(id, attributes = T.let({}, Attributes)) ⇒ Cluster
constructor
A new instance of Cluster.
- #inspect ⇒ Object
- #remove_vertex(vertex) ⇒ Object
Constructor Details
#initialize(id, attributes = T.let({}, Attributes)) ⇒ Cluster
Returns a new instance of Cluster.
23 24 25 26 27 |
# File 'lib/mosaik/graph/cluster.rb', line 23 def initialize(id, attributes = T.let({}, Attributes)) @attributes = attributes @id = id @vertices = T.let(Set.new, T::Set[Vertex]) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
20 21 22 |
# File 'lib/mosaik/graph/cluster.rb', line 20 def attributes @attributes end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/mosaik/graph/cluster.rb', line 14 def id @id end |
#vertices ⇒ Object (readonly)
Returns the value of attribute vertices.
17 18 19 |
# File 'lib/mosaik/graph/cluster.rb', line 17 def vertices @vertices end |
Instance Method Details
#add_vertex(vertex) ⇒ Object
30 31 32 |
# File 'lib/mosaik/graph/cluster.rb', line 30 def add_vertex(vertex) vertices << vertex end |
#inspect ⇒ Object
40 41 42 |
# File 'lib/mosaik/graph/cluster.rb', line 40 def inspect "#<#{self.class.name} id=#{id} vertices=#{vertices.size} attributes=#{attributes.map { |k, v| "#{k}: #{v}" }.join(', ')}>" end |
#remove_vertex(vertex) ⇒ Object
35 36 37 |
# File 'lib/mosaik/graph/cluster.rb', line 35 def remove_vertex(vertex) vertices.delete(vertex) end |