~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to tcldot/tcldot.n

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.TH TCLDOT N "02 December 1996"
 
2
 
 
3
.SH NAME
 
4
 
 
5
tcldot \- graph manipulation in tcl
 
6
 
 
7
.SH SYNOPSIS
 
8
 
 
9
#!/usr/local/bin/tclsh
 
10
.br
 
11
package require \fBTcldot\fR
 
12
 
 
13
.SH USAGE
 
14
Requires the dynamic loading facilities of tcl7.6 or later.
 
15
 
 
16
.SH INTRODUCTION
 
17
 
 
18
.B tcldot
 
19
is a tcl dynamically loaded extension that incorporates
 
20
the directed graph facilities of 
 
21
.B dot(1), 
 
22
and the undirected graph facilities of
 
23
.B neato(1),
 
24
into tcl and provides a set of commands to control those
 
25
facilities.
 
26
.B tcldot
 
27
converts
 
28
.B dot
 
29
and 
 
30
.B neato
 
31
from batch processing tools to an interpreted and, if needed, interactive set
 
32
of graph manipulation facilities.
 
33
 
 
34
.SH COMMANDS
 
35
 
 
36
.B tcldot
 
37
initially adds only three commands to tcl, namely
 
38
.B dotnew,
 
39
.B dotread,
 
40
and
 
41
.B dotstring.
 
42
These commands return a handle for the graph that has just been created
 
43
and that handle can then be used as a command for further actions on the graph.
 
44
 
 
45
All other "commands" are of the form:
 
46
.IP
 
47
.I handle
 
48
.B <method>
 
49
.I parameters
 
50
.PP
 
51
Many of the methods return further
 
52
handles of graphs, nodes of edges, which are themselves registered as commands.
 
53
 
 
54
The methods are described in detail below, but in summary:
 
55
.PP
 
56
Graph methods are:
 
57
.IP
 
58
.B "addedge, addnode, addsubgraph, countedges, countnodes, layout, listattributes, listedgeattributes, listnodeattributes, listedges, listnodes, listsubgraphs, render, rendergd, queryattributes, queryedgeattributes, querynodeattributes, queryattributevalues, queryedgeattributevalues, querynodeattributevalues, setattributes, setedgeattributes, setnodeattributes, showname, write."
 
59
.PP
 
60
Node methods are:
 
61
.IP
 
62
.B "addedge, listattributes, listedges, listinedges, listoutedges, queryattributes, queryattributevalues, setattributes, showname."
 
63
.PP
 
64
Edge methods are: 
 
65
.IP
 
66
.B "delete, listattributes, listnodes, queryattributes, queryattributevalues, setattributes, showname."
 
67
 
 
68
.TP
 
69
\fBdotnew\fR \fIgraphType ?attributeName attributeValue? ?...?\fR
 
70
 
 
71
creates a new empty graph and returns its 
 
72
.I graphHandle.
 
73
 
 
74
.I graphType
 
75
can be any supported by 
 
76
.B dot(1)
 
77
namely: "graph," "digraph," "graphstrict," or "digraphstrict."
 
78
(In digraphs edges have a direction from tail to head. "Strict" graphs
 
79
or digraphs collapse multiple edges between the same pair of
 
80
nodes into a single edge.)
 
81
 
 
82
Following the mandatory 
 
83
.I graphType
 
84
parameter the 
 
85
.B dotnew
 
86
command will accept an arbitrary number of attribute name/value pairs
 
87
for the graph.
 
88
Certain special graph attributes and permitted values are described in
 
89
.B dot(1), 
 
90
but the programmer can arbitrarily invent and assign values
 
91
to additional attributes beyond these.
 
92
In 
 
93
.B dot
 
94
the attribute name is separated from the value by an "=" character.
 
95
In
 
96
.B tcldot
 
97
the "=" has been replaced by a " " (space)  to be more consistent
 
98
with
 
99
.B tcl
 
100
syntax.
 
101
e.g.
 
102
.nf
 
103
 
 
104
    set g [dotnew digraph rankdir LR]
 
105
 
 
106
.fi
 
107
.TP
 
108
\fBdotread\fR \fIfileHandle\fR
 
109
 
 
110
reads in a dot-language description of a graph from a previously opened
 
111
file identified by the 
 
112
.I fileHandle.
 
113
The command returns the
 
114
.I graphHandle
 
115
of the newly read graph.  e.g.
 
116
.nf
 
117
 
 
118
    set f [open test.dot r]
 
119
    set g [dotread $f]
 
120
 
 
121
.fi
 
122
.TP
 
123
\fBdotstring\fR \fIstring\fR
 
124
 
 
125
reads in a dot-language description of a graph from a Tcl string;
 
126
The command returns the
 
127
.I graphHandle
 
128
of the newly read graph.  e.g.
 
129
.nf
 
130
 
 
131
    set g [dotread $dotsyntaxstring]
 
132
 
 
133
.fi
 
134
.TP
 
135
\fIgraphHandle\fR \fBaddnode\fR \fI?nodeName? ?attributeName attributeValue? ?...?\fR
 
136
 
 
137
creates a new node in the graph whose handle is
 
138
.I graphHandle
 
139
and returns its
 
140
.I nodeHandle.
 
141
The handle of a node is a string like: "node0" where the integer value is
 
142
different for each node.
 
143
There can be an arbitrary number of attribute name/value pairs
 
144
for the node.
 
145
Certain special node attributes and permitted values are described in
 
146
.B dot(1), 
 
147
but the programmer can arbitrarily invent and assign values
 
148
to additional attributes beyond these.
 
149
e.g.
 
150
.nf
 
151
 
 
152
    set n [$g addnode "N" label "Top\\nNode" shape triangle eggs easyover]
 
153
 
 
154
.fi
 
155
A possible cause of confusion in 
 
156
.B tcldot
 
157
is the distinction between handles, names, labels, and variables.
 
158
The distinction is primarily in who owns them.
 
159
Handles are owned by tcldot and are guaranteed to be unique within
 
160
one interpreter session.  Typically handles are assigned to variables,
 
161
like "n" above, for manipulation within a tcl script.
 
162
Variables are owned by the programmer.
 
163
Names are owned by the application that is using the
 
164
graph, typically names are important when reading in a graph from
 
165
an external program or file.  Labels are the text that is displayed with
 
166
the node
 
167
(or edge) when the graph is displayed, labels are meaningful to the
 
168
reader of the graph.  Only the handles and variables are essential to 
 
169
.B tcldot's
 
170
ability to manipulate abstract graphs.  If a name is not specified then
 
171
it defaults to the string representation of the handle, if a label is
 
172
not specified then it defaults to the name.
 
173
 
 
174
.TP
 
175
\fIgraphHandle\fR \fBaddedge\fR \fItailNode headNode ?attributeName attributeValue? ?...?\fR
 
176
 
 
177
creates a new edge in the graph whose handle is
 
178
.I graphHandle
 
179
and returns its
 
180
.B edgeHandle.
 
181
.I tailNode 
 
182
and
 
183
.I headNode
 
184
can be specified either by their
 
185
.I nodeHandle
 
186
or by their 
 
187
.I nodeName.
 
188
e.g.
 
189
.nf
 
190
 
 
191
    set n [$g addnode]
 
192
    set m [$g addnode]
 
193
    $g addedge $n $m label "NM"
 
194
 
 
195
    $g addnode N
 
196
    $g addnode M
 
197
    $g addedge N M label "NM"
 
198
 
 
199
.fi
 
200
The argument is recognized as a handle if possible and so it is best
 
201
to avoid names like "node6" for nodes.  If there is potential for conflict then use
 
202
.B findnode
 
203
to translate explicitly from names to handles.
 
204
e.g.
 
205
.nf
 
206
 
 
207
    $g addnode "node6"
 
208
    $g addnode "node99"
 
209
    $g addedge [$g findnode "node6"] [$g findnode "node99"]
 
210
 
 
211
.fi
 
212
There can be an arbitrary number of attribute name/value pairs
 
213
for the edge.
 
214
Certain special edge attributes and permitted values are described in
 
215
.B dot(1), 
 
216
but the programmer can arbitrarily invent and assign values
 
217
to additional attributes beyond these.
 
218
 
 
219
.TP
 
220
\fIgraphHandle\fR \fBaddsubgraph\fR \fI?graphName? ?attributeName attributeValue? ?...?\fR
 
221
 
 
222
creates a new subgraph in the graph and returns its
 
223
.I graphHandle.
 
224
If the
 
225
.I graphName
 
226
is omitted then the name of the subgraph defaults to it's 
 
227
.I graphHandle.
 
228
There can be an arbitrary number of attribute name/value pairs
 
229
for the subgraph.
 
230
Certain special graph attributes and permitted values are described in
 
231
.B dot(1), 
 
232
but the programmer can arbitrarily invent and assign values
 
233
to additional attributes beyond these.
 
234
e.g.
 
235
.nf
 
236
 
 
237
    set sg [$g addsubgraph dinglefactor 6]
 
238
 
 
239
.fi
 
240
Clusters, as described in
 
241
.B dot(1),
 
242
are created by giving the subgraph a name that begins with the string:
 
243
"cluster".  Cluster can be labelled by using the \fIlabel\fR attibute.
 
244
e.g.
 
245
.nf
 
246
 
 
247
    set cg [$g addsubgraph cluster_A label dongle dinglefactor 6]
 
248
 
 
249
.fi
 
250
.TP
 
251
\fInodeHandle\fR \fBaddedge\fR \fIheadNode ?attributeName attributeValue? ?...?\fR
 
252
 
 
253
creates a new edge from the tail node identified by tha
 
254
.I nodeHandle
 
255
to the 
 
256
.I headNode
 
257
which can be specified either by 
 
258
.I nodeHandle
 
259
or by 
 
260
.I nodeName
 
261
(with preference to recognizing the argument as a handle).
 
262
The graph in which this is drawn is the graph in which both nodes are
 
263
members.
 
264
There can be an arbitrary number of attribute name/value pairs
 
265
for the edge.
 
266
These edge attributes and permitted values are described in
 
267
.B dot(1).
 
268
e.g.
 
269
.nf
 
270
 
 
271
    [$g addnode] addedge [$g addnode] label "NM"
 
272
 
 
273
.fi
 
274
.TP 
 
275
\fIgraphHandle\fR \fBdelete\fR
 
276
.TP
 
277
\fInodeHandle\fR \fBdelete\fR
 
278
.TP
 
279
\fIedgeHandle\fR \fBdelete\fR
 
280
 
 
281
Delete all data structures associated with the graph, node or edge
 
282
from the internal storage of the interpreter.  Deletion of a node also
 
283
results in the the deletion of all subtending edges on that node.
 
284
Deletion of a graph also results in the deletion of all nodes and
 
285
subgraphs within that graph (and hence all edges too).  The return from
 
286
these delete commands is a null string.
 
287
 
 
288
.TP
 
289
\fIgraphHandle\fR \fBcountnodes\fR
 
290
.TP
 
291
\fIgraphHandle\fR \fBcountedges\fR
 
292
 
 
293
Returns the number of nodes, or edges, in the graph.
 
294
 
 
295
.TP
 
296
\fIgraphHandle\fR \fBlistedges\fR
 
297
.TP
 
298
\fIgraphHandle\fR \fBlistnodes\fR
 
299
.TP
 
300
\fIgraphHandle\fR \fBlistsubgraphs\fR
 
301
.TP
 
302
\fInodeHandle\fR \fBlistedges\fR
 
303
.TP
 
304
\fInodeHandle\fR \fBlistinedges\fR
 
305
.TP
 
306
\fInodeHandle\fR \fBlistoutedges\fR
 
307
.TP
 
308
\fIedgeHandle\fR \fBlistnodes\fR
 
309
 
 
310
Each return a list of handles of graphs, nodes or edges, as appropriate.
 
311
 
 
312
.TP
 
313
\fIgraphHandle\fR \fBfindnode\fR \fInodeName\fR
 
314
.TP
 
315
\fIgraphHandle\fR \fBfindedge\fR \fItailnodeName headNodeName\fR
 
316
.TP
 
317
\fInodeHandle\fR \fBfindedge\fR \fInodeName\fR
 
318
 
 
319
Each return the handle of the item if found, or an error if none are found.  
 
320
For non-strict graphs when there are multiple edges between two nodes
 
321
.B findedge
 
322
will return an arbitrary edge from the set.
 
323
 
 
324
.TP
 
325
\fIgraphHandle\fR \fBshowname\fR
 
326
.TP
 
327
\fInodeHandle\fR \fBshowname\fR
 
328
.TP
 
329
\fIedgeHandle\fR \fBshowname\fR
 
330
 
 
331
Each return the name of the item.  Edge names are of the form:
 
332
"a->b" where "a" and "b" are the names of the nodes and the connector
 
333
"->" indicates the tail-to-head direction of the edge. In undirected
 
334
graphs the connector "--" is used.
 
335
 
 
336
.TP
 
337
\fIgraphHandle\fR \fBsetnodeattributes\fR \fIattributeName attributeValue ?...?\fR
 
338
.TP
 
339
\fIgraphHandle\fR \fBsetedgeattributes\fR \fIattributeName attributeValue ?...?\fR
 
340
 
 
341
Set one or more default attribute name/values that are to apply to
 
342
all nodes (edges) unless overridden by subgraphs or per-node
 
343
(per-edge) attributes. 
 
344
 
 
345
.TP
 
346
\fIgraphHandle\fR \fBlistnodeattributes\fR
 
347
.TP
 
348
\fIgraphHandle\fR \fBlistedgeattributes\fR
 
349
 
 
350
Return a list of attribute names.
 
351
 
 
352
.TP
 
353
\fIgraphHandle\fR \fBquerynodeattributes\fR \fIattributeName ?...?\fR
 
354
.TP
 
355
\fIgraphHandle\fR \fBqueryedgeattributes\fR \fIattributeName ?...?\fR
 
356
 
 
357
Return a list of default attribute value, one value for each of the
 
358
attribute names provided with the command.
 
359
 
 
360
.TP
 
361
\fIgraphHandle\fR \fBquerynodeattributes\fR \fIattributeName ?...?\fR
 
362
.TP
 
363
\fIgraphHandle\fR \fBqueryedgeattributes\fR \fIattributeName ?...?\fR
 
364
 
 
365
Return a list of pairs of attrinute name and default attribute value,
 
366
one pair for each of the attribute names provided with the command.
 
367
 
 
368
.TP
 
369
\fIgraphHandle\fR \fBsetattributes\fR \fIattributeName attributeValue ?...?\fR
 
370
.TP
 
371
\fInodeHandle\fR \fBsetattributes\fR \fIattributeName attributeValue ?...?\fR
 
372
.TP
 
373
\fIedgeHandle\fR \fBsetattributes\fR \fIattributeName attributeValue ?...?\fR
 
374
 
 
375
Set one or more attribute name/value pairs for a specific graph, node,
 
376
or edge instance.
 
377
 
 
378
.TP
 
379
\fIgraphHandle\fR \fBlistattributes\fR
 
380
.TP
 
381
\fInodeHandle\fR \fBlistattributes\fR
 
382
.TP
 
383
\fIedgeHandle\fR \fBlistattributes\fR
 
384
 
 
385
Return a list of attribute names (attribute values are provided by
 
386
.B queryattribute
 
387
 
 
388
.TP
 
389
\fIgraphHandle\fR \fBqueryattributes\fR \fIattributeName ?...?\fR
 
390
.TP
 
391
\fInodeHandle\fR \fBqueryattributes\fR \fIattributeName ?...?\fR
 
392
.TP
 
393
\fIedgeHandle\fR \fBqueryattributes\fR \fIattributeName ?...?\fR
 
394
 
 
395
Return a list of attribute value, one value for each of the
 
396
attribute names provided with the command.
 
397
 
 
398
.TP
 
399
\fIgraphHandle\fR \fBqueryattributevalues\fR \fIattributeName ?...?\fR
 
400
.TP
 
401
\fInodeHandle\fR \fBqueryattributevalues\fR \fIattributeName ?...?\fR
 
402
.TP
 
403
\fIedgeHandle\fR \fBqueryattributevalues\fR \fIattributeName ?...?\fR
 
404
 
 
405
Return a list of pairs or attribute name and attribute value,
 
406
one value for each of the attribute names provided with the command.
 
407
 
 
408
.TP
 
409
\fIgraphHandle\fR \fBlayout ?DOT|NEATO?\fR
 
410
 
 
411
Annotate the graph with layout information.  This commands takes an
 
412
abstract graph add shape and position information to it according to 
 
413
.B dot's
 
414
or
 
415
.B neato's
 
416
rules of eye-pleasing graph layout. If the layout engine is
 
417
unspecified then it defaults to DOT for directed graphs, and NEATO otherwise.
 
418
The result of the layout is stored
 
419
as additional attributes name/value pairs in the graph, node and edges.
 
420
These attributes are intended to be interpreted by subsequent 
 
421
.I write
 
422
or
 
423
.I render
 
424
commands.
 
425
 
 
426
.TP
 
427
\fIgraphHandle\fR \fBwrite\fR \fIfileHandle format ?DOT|NEATO?\fR
 
428
 
 
429
Write a graph to the open file represented by
 
430
.I fileHandle
 
431
in a specific
 
432
.I format.
 
433
Possible
 
434
.I formats
 
435
are: "ps" "mif" "hpgl" "plain" "dot" "gif" "ismap"
 
436
If the layout hasn't been already done, then it will be done as part
 
437
of this operation using the same rules for selecting the layout engine
 
438
as for the layout command.
 
439
 
 
440
.TP
 
441
\fIgraphHandle\fR \fBrendergd\fR \fIgdHandle\fR
 
442
 
 
443
Generates a rendering of a graph to a new
 
444
or existing gifImage structure (see
 
445
.B gdTcl(1)
 
446
).  Returns the 
 
447
.I gdHandle
 
448
of the image.
 
449
If the layout hasn't been already done, then it will be done as part
 
450
of this operation using the same rules for selecting the layout engine
 
451
as for the layout command.
 
452
 
 
453
.TP
 
454
\fIgraphHandle\fR \fBrender\fR \fI?canvas ?DOT|NEATO??\fR
 
455
 
 
456
If no \fIcanvas\fR argument is provided then \fBrender\fR
 
457
returns a string of commands which, when evaluated, will render the
 
458
graph to a 
 
459
.B Tk
 
460
canvas whose 
 
461
.I canvasHandle
 
462
is available in variable 
 
463
.B $c
 
464
 
 
465
If a \fIcanvas\fR argument is provided then \fBrender\fR
 
466
produces a set of commands for \fIcanvas\fR instead of $c.
 
467
 
 
468
If the layout hasn't been already done, then it will be done as part
 
469
of this operation using the same rules for selecting the layout engine
 
470
as for the layout command.
 
471
.nf
 
472
 
 
473
    #!/usr/local/bin/wish
 
474
    package require Tcldot
 
475
    set c [canvas .c]
 
476
    pack $c
 
477
    set g [dotnew digraph rankdir LR]
 
478
    $g setnodeattribute style filled color white
 
479
    [$g addnode Hello] addedge [$g addnode World!]
 
480
    $g layout
 
481
    if {[info exists debug]} {
 
482
        puts [$g render]         ;# see what render produces
 
483
    }
 
484
    eval [$g render]
 
485
 
 
486
.fi
 
487
 
 
488
.B Render
 
489
generates a series of canvas commands for each graph element, for example
 
490
a node typically consist of two items on the canvas, one for the shape
 
491
and the other for the label.  The canvas items are automatically 
 
492
.I tagged
 
493
(See
 
494
.B canvas(n)
 
495
) by the commands generated by render.  The tags take one of two forms:
 
496
text items are tagged with 0<handle> and
 
497
shapes and lines are rendered with 1<handle>.
 
498
 
 
499
The tagging can be used to recognize when a user wants to interact with
 
500
a graph element using the mouse.  See the script in
 
501
.I examples/disp
 
502
of the tcldot distribution for a demonstration of this facility.
 
503
 
 
504
.SH BUGS
 
505
 
 
506
Still batch-oriented.  It would be nice if the layout was maintained incrementally.
 
507
(The intent is to address this limitation in graphviz_2_0.)
 
508
 
 
509
.SH AUTHOR
 
510
 
 
511
John Ellson, Lucent Technologies, Holmdel, NJ. (ellson@lucent.com)
 
512
 
 
513
.SH ACKNOWLEDGEMENTS
 
514
 
 
515
John Ousterhout, of course, for 
 
516
.B tcl
 
517
and
 
518
.B tk.
 
519
Steven North and Eleftherios Koutsofios for
 
520
.B dot.
 
521
Karl Lehenbauer and Mark Diekhans of NeoSoft
 
522
for the handles.c code which was derived from tclXhandles.c.
 
523
Tom Boutell of the Quest Center at Cold Spring Harbor Labs for the gif drawing routines.
 
524
Spencer Thomas of the University of Michigan for gdTcl.c.
 
525
Dayatra Shands for coding much of the initial implementation of 
 
526
.B tcldot.
 
527
 
 
528
.SH KEYWORDS
 
529
 
 
530
graph, tcl, tk, dot, neato.