Class: DecisionAgent::Dmn::TreeDotGenerator
- Inherits:
-
Object
- Object
- DecisionAgent::Dmn::TreeDotGenerator
- Defined in:
- lib/decision_agent/dmn/visualizer.rb
Overview
Generates DOT format for decision trees (for Graphviz)
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(decision_tree) ⇒ TreeDotGenerator
constructor
A new instance of TreeDotGenerator.
Constructor Details
#initialize(decision_tree) ⇒ TreeDotGenerator
Returns a new instance of TreeDotGenerator.
202 203 204 |
# File 'lib/decision_agent/dmn/visualizer.rb', line 202 def initialize(decision_tree) @tree = decision_tree end |
Instance Method Details
#generate ⇒ Object
206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/decision_agent/dmn/visualizer.rb', line 206 def generate dot = ["digraph decision_tree {"] dot << " graph [rankdir=TB, splines=ortho];" dot << " node [shape=box, style=rounded];" generate_nodes(@tree.root, dot) generate_edges(@tree.root, dot) dot << "}" dot.join("\n") end |