1gv(3lua) gv(3lua)
2
3
4
6 gv_lua - graph manipulation in lua
7
8
10 #!/usr/bin/lua
11 require('gv')
12
13
16 gv_lua is a dynamically loaded extension for lua 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 an open channel
204 bool gv.renderchannel (graph_handle, string format, string chan‐
205 nelname);
206
207 Render to a string result
208 gv.renderresult (graph_handle, string format, string outdata);
209
210 Render a layout to a malloc'ed string, to be free'd by the caller
211
212 (deprecated - too easy to leak memory)
213
214 (still needed for "eval [gv::renderdata $G tk]" )
215 string gv.renderdata (graph_handle, string format);
216
217 Writing graph back to file
218 bool gv.write (graph_handle, string filename);
219 bool gv.write (graph_handle, channel);
220
221
223 graph, dot, neato, fdp, circo, twopi, lua.
224
225
226
227
228 10 December 2009 gv(3lua)