Class: Graphviz::Graph
- Inherits:
-
Object
- Object
- Graphviz::Graph
- Defined in:
- lib/graphviz/graph.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#edges ⇒ Object
readonly
Returns the value of attribute edges.
-
#graphs ⇒ Object
readonly
Returns the value of attribute graphs.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
- #add_node(name, attributes = {}) ⇒ Object
- #add_subgraph(name, attributes = {}) ⇒ Object
- #attach(parent) ⇒ Object
-
#initialize(name = 'G', attributes = {}) ⇒ Graph
constructor
A new instance of Graph.
- #to_dot(options = {}) ⇒ Object
Constructor Details
#initialize(name = 'G', attributes = {}) ⇒ Graph
Returns a new instance of Graph.
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/graphviz/graph.rb', line 90 def initialize(name = 'G', attributes = {}) @name = name @nodes = {} @edges = [] @graphs = {} @parent = nil @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
106 107 108 |
# File 'lib/graphviz/graph.rb', line 106 def attributes @attributes end |
#edges ⇒ Object (readonly)
Returns the value of attribute edges.
103 104 105 |
# File 'lib/graphviz/graph.rb', line 103 def edges @edges end |
#graphs ⇒ Object (readonly)
Returns the value of attribute graphs.
104 105 106 |
# File 'lib/graphviz/graph.rb', line 104 def graphs @graphs end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
102 103 104 |
# File 'lib/graphviz/graph.rb', line 102 def nodes @nodes end |
Instance Method Details
#add_node(name, attributes = {}) ⇒ Object
108 109 110 |
# File 'lib/graphviz/graph.rb', line 108 def add_node(name, attributes = {}) Node.new(self, name, attributes) end |
#add_subgraph(name, attributes = {}) ⇒ Object
112 113 114 115 116 117 118 119 |
# File 'lib/graphviz/graph.rb', line 112 def add_subgraph(name, attributes = {}) graph = Graph.new(name, attributes) graph.attach(self) @graphs[name] = graph return graph end |
#attach(parent) ⇒ Object
121 122 123 |
# File 'lib/graphviz/graph.rb', line 121 def attach(parent) @parent = parent end |
#to_dot(options = {}) ⇒ Object
125 126 127 128 129 130 131 |
# File 'lib/graphviz/graph.rb', line 125 def to_dot( = {}) buffer = StringIO.new dump_graph(buffer, "", ) return buffer.string end |