summaryrefslogtreecommitdiff
path: root/graphics/circuit_macros/examples/svg/BtreeSVG.m4
blob: 312249605ee30bf837af772ba9621f08a256d703 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
.PS
# Btree.m4
# One way to draw a binary tree using pic macros
gen_init(svg_font(sans-serif,11bp__))
circlerad = 0.30

define n { [C: circle fill_(0.9) $1
            if "$2" != "" then {
              L: $2 with .ne at C.s-(circlerad/20, circlerad/2)
              line from C to L.C chop }
            if "$3" != "" then {
              R: $3 with .nw at C.s+(circlerad/20,-circlerad/2)
              line from C to R.C chop }
            ] }

# Redrawn from T. A. Standish, "Data Structure Techniques," Addison-Wesley 1980.
# Node data:
define Sirius { n("Sirius",Canopus,Vega) }
define Canopus { n("Canopus",AlphaCentauri,Capella) }
define AlphaCentauri { n("Alpha" "Centauri",Achernar,Arcturus) }
define Arcturus { n("Arcturus",Betelgeux) }
define Betelgeux { n("Betelgeux",BetaCentauri) }
define Capella { n("Capella",Rigel) }
define Rigel { n("Rigel",Procyon) }
define Achernar { n("Achernar") }
define BetaCentauri { n("Beta" "Centauri") }
define Procyon { n("Procyon") }
define Vega { n("Vega") }

# Build the tree from the root
S: Sirius
 command "</g>" # end font
.PE