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

« back to all changes in this revision

Viewing changes to tcldot/demo/gcat

  • 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
#!/bin/sh
 
2
# next line is a comment in tcl \
 
3
exec tclsh "$0" ${1+"$@"}
 
4
 
 
5
package require Tcldot
 
6
 
 
7
#  gcat f1 [f2 ... ]
 
8
#
 
9
# merge a number of digraphs into one and output to stdout
 
10
#
 
11
# John Ellson  <ellson@lucent.com>
 
12
 
13
 
 
14
# merge graph $g2 into $g
 
15
proc merge {g g2} {
 
16
        foreach i [$g2 listnodes] {
 
17
                set n [$g addnode [$i showname]]
 
18
                $n setattributes [$i queryattributevalues [$i listattributes]]
 
19
        }
 
20
        foreach i [$g2 listedges] {
 
21
                foreach {t h} [$i listnodes] {break}
 
22
                set e [$g addedge [$t showname] [$h showname]]
 
23
                $e setattributes [$i queryattributevalues [$i listattributes]]
 
24
        }
 
25
}
 
26
 
 
27
set g [dotnew digraph]
 
28
if {$argc} {
 
29
        foreach file $argv {
 
30
                set f [open $file r]
 
31
                if {[catch {dotread $f} g2]} {
 
32
                        puts stderr $g2
 
33
                        exit
 
34
                }
 
35
                merge $g $g2
 
36
                close $f
 
37
        }
 
38
} {
 
39
        while {![catch {dotread stdin} g2]} {
 
40
                merge $g $g2
 
41
        }
 
42
        if {![eof stdin]} {
 
43
                puts stderr $g2
 
44
                exit
 
45
        }
 
46
}
 
47
$g write stdout CANON