1gv(3ruby) gv(3ruby)
2
3
4
6 gv_ruby - graph manipulation in ruby
7
8
10 #!/usr/bin/ruby
11 require 'gv'
12
13
16 gv_ruby is a dynamically loaded extension for ruby that provides access
17 to the graph facilities of graphviz.
18
19
21 New graphs
22
23 New empty graph
24 graph_handle Gv.graph (name);
25 graph_handle Gv.digraph (name);
26 graph_handle Gv.strictgraph (name);
27 graph_handle Gv.strictdigraph (name);
28
29 New graph from a dot-syntax string or file
30 graph_handle Gv.readstring (string);
31 graph_handle Gv.read (string filename);
32 graph_handle Gv.read (channel);
33
34 Add new subgraph to existing graph
35 graph_handle Gv.graph (graph_handle, name);
36
37 New nodes
38
39 Add new node to existing graph
40 node_handle Gv.node (graph_handle, name);
41
42 New edges
43
44 Add new edge between existing nodes
45 edge_handle Gv.edge (tail_node_handle, head_node_handle);
46
47 Add a new edge between an existing tail node, and a named head node
48 which will be induced in the graph if it doesn't already exist
49 edge_handle Gv.edge (tail_node_handle, head_name);
50
51 Add a new edge between an existing head node, and a named tail node
52 which will be induced in the graph if it doesn't already exist
53 edge_handle Gv.edge (tail_name, head_node_handle);
54
55 Add a new edge between named tail and head nodes which will be induced
56 in the graph if they don't already exist
57 edge_handle Gv.edge (graph_handle, tail_name, head_name);
58
59 Setting attribute values
60
61 Set value of named attribute of graph/node/edge - creating attribute if
62 necessary
63 string Gv.setv (graph_handle, attr_name, attr_value);
64 string Gv.setv (node_handle, attr_name, attr_value);
65 string Gv.setv (edge_handle, attr_name, attr_value);
66
67 Set value of existing attribute of graph/node/edge (using attribute
68 handle)
69 string Gv.setv (graph_handle, attr_handle, attr_value);
70 string Gv.setv (node_handle, attr_handle, attr_value);
71 string Gv.setv (edge_handle, attr_handle, attr_value);
72
73 Getting attribute values
74
75 Get value of named attribute of graph/node/edge
76 string Gv.getv (graph_handle, attr_name);
77 string Gv.getv (node_handle, attr_name);
78 string Gv.getv (edge_handle, attr_name);
79
80 Get value of attribute of graph/node/edge (using attribute handle)
81 string Gv.getv (graph_handle, attr_handle);
82 string Gv.getv (node_handle, attr_handle);
83 string Gv.getv (edge_handle, attr_handle);
84
85 Obtain names from handles
86 string Gv.nameof (graph_handle);
87 string Gv.nameof (node_handle);
88 string Gv.nameof (attr_handle);
89
90 Find handles from names
91 graph_handle Gv.findsubg (graph_handle, name);
92 node_handle Gv.findnode (graph_handle, name);
93 edge_handle Gv.findedge (tail_node_handle, head_node_handle);
94 attribute_handle Gv.findattr (graph_handle, name);
95 attribute_handle Gv.findattr (node_handle, name);
96 attribute_handle Gv.findattr (edge_handle, name);
97
98 Misc graph navigators returning handles
99 node_handle Gv.headof (edge_handle);
100 node_handle Gv.tailof (edge_handle);
101 graph_handle Gv.graphof (graph_handle);
102 graph_handle Gv.graphof (edge_handle);
103 graph_handle Gv.graphof (node_handle);
104 graph_handle Gv.rootof (graph_handle);
105
106 Obtain handles of proto node/edge for setting default attribute values
107 node_handle Gv.protonode (graph_handle);
108 edge_handle Gv.protoedge (graph_handle);
109
110 Iterators
111
112 Iteration termination tests
113 bool Gv.ok (graph_handle);
114 bool Gv.ok (node_handle);
115 bool Gv.ok (edge_handle);
116 bool Gv.ok (attr_handle);
117
118 Iterate over subgraphs of a graph
119 graph_handle Gv.firstsubg (graph_handle);
120 graph_handle Gv.nextsubg (graph_handle, subgraph_handle);
121
122 Iterate over supergraphs of a graph (obscure and rarely useful)
123 graph_handle Gv.firstsupg (graph_handle);
124 graph_handle Gv.nextsupg (graph_handle, subgraph_handle);
125
126 Iterate over edges of a graph
127 edge_handle Gv.firstedge (graph_handle);
128 edge_handle Gv.nextedge (graph_handle, edge_handle);
129
130 Iterate over outedges of a graph
131 edge_handle Gv.firstout (graph_handle);
132 edge_handle Gv.nextout (graph_handle, edge_handle);
133
134 Iterate over edges of a node
135 edge_handle Gv.firstedge (node_handle);
136 edge_handle Gv.nextedge (node_handle, edge_handle);
137
138 Iterate over out-edges of a node
139 edge_handle Gv.firstout (node_handle);
140 edge_handle Gv.nextout (node_handle, edge_handle);
141
142 Iterate over head nodes reachable from out-edges of a node
143 node_handle Gv.firsthead (node_handle);
144 node_handle Gv.nexthead (node_handle, head_node_handle);
145
146 Iterate over in-edges of a graph
147 edge_handle Gv.firstin (graph_handle);
148 edge_handle Gv.nextin (node_handle, edge_handle);
149
150 Iterate over in-edges of a node
151 edge_handle Gv.firstin (node_handle);
152 edge_handle Gv.nextin (graph_handle, edge_handle);
153
154 Iterate over tail nodes reachable from in-edges of a node
155 node_handle Gv.firsttail (node_handle);
156 node_handle Gv.nexttail (node_handle, tail_node_handle);
157
158 Iterate over nodes of a graph
159 node_handle Gv.firstnode (graph_handle);
160 node_handle Gv.nextnode (graph_handle, node_handle);
161
162 Iterate over nodes of an edge
163 node_handle Gv.firstnode (edge_handle);
164 node_handle Gv.nextnode (edge_handle, node_handle);
165
166 Iterate over attributes of a graph
167 attribute_handle Gv.firstattr (graph_handle);
168 attribute_handle Gv.nextattr (graph_handle, attr_handle);
169
170 Iterate over attributes of an edge
171 attribute_handle Gv.firstattr (edge_handle);
172 attribute_handle Gv.nextattr (edge_handle, attr_handle);
173
174 Iterate over attributes of a node
175 attribute_handle Gv.firstattr (node_handle);
176 attribute_handle Gv.nextattr (node_handle, attr_handle);
177
178 Remove graph objects
179 bool Gv.rm (graph_handle);
180 bool Gv.rm (node_handle);
181 bool Gv.rm (edge_handle);
182
183 Layout
184
185 Annotate a graph with layout attributes and values using a specific
186 layout engine
187 bool Gv.layout (graph_handle, string engine);
188
189 Render
190
191 Render a layout into attributes of the graph
192 bool Gv.render (graph_handle);
193
194 Render a layout to stdout
195 bool Gv.render (graph_handle, string format);
196
197 Render to an open file
198 bool Gv.render (graph_handle, string format, channel fout);
199
200 Render a layout to an unopened file by name
201 bool Gv.render (graph_handle, string format, string filename);
202
203 Render to a string result
204 string Gv.renderresult (graph_handle ing, string format);
205 Gv.renderresult (graph_handle, string format, string outdata);
206
207 Render to an open channel
208 bool Gv.renderchannel (graph_handle, string format, string chan‐
209 nelname);
210
211 Render a layout to a malloc'ed string, to be free'd by the caller
212
213 (deprecated - too easy to leak memory)
214
215 (still needed for "eval [gv::renderdata $G tk]" )
216 string Gv.renderdata (graph_handle, string format);
217
218 Writing graph back to file
219 bool Gv.write (graph_handle, string filename);
220 bool Gv.write (graph_handle, channel);
221
222 Graph transformation tools
223 bool Gv.tred (graph_handle);
224
225
227 graph, dot, neato, fdp, circo, twopi, ruby.
228
229
230
231
232 07 July 2023 gv(3ruby)