Class: Mementus::GraphBuilder
- Inherits:
-
Object
- Object
- Mementus::GraphBuilder
- Defined in:
- lib/mementus/graph_builder.rb
Instance Method Summary collapse
- #add_edge(edge) ⇒ Object
- #add_node(node) ⇒ Object
- #create_edge {|edge| ... } ⇒ Object
- #create_node {|node| ... } ⇒ Object
- #graph ⇒ Object
-
#initialize(is_directed) ⇒ GraphBuilder
constructor
A new instance of GraphBuilder.
Constructor Details
#initialize(is_directed) ⇒ GraphBuilder
3 4 5 |
# File 'lib/mementus/graph_builder.rb', line 3 def initialize(is_directed) @structure = Structure::AdjacencyList.new(is_directed) end |
Instance Method Details
#add_edge(edge) ⇒ Object
23 24 25 |
# File 'lib/mementus/graph_builder.rb', line 23 def add_edge(edge) @structure.add_edge(edge) end |
#add_node(node) ⇒ Object
7 8 9 |
# File 'lib/mementus/graph_builder.rb', line 7 def add_node(node) @structure.add_node(node) end |
#create_edge {|edge| ... } ⇒ Object
11 12 13 14 15 |
# File 'lib/mementus/graph_builder.rb', line 11 def create_edge(&block) edge = EdgeBuilder.new yield edge @structure.add_edge(edge) end |
#create_node {|node| ... } ⇒ Object
17 18 19 20 21 |
# File 'lib/mementus/graph_builder.rb', line 17 def create_node(&block) node = NodeBuilder.new yield node @structure.add_node(node) end |
#graph ⇒ Object
27 28 29 |
# File 'lib/mementus/graph_builder.rb', line 27 def graph @structure end |