diff options
Diffstat (limited to 'graphics/circuit_macros/examples/svg/BtreeSVG.m4')
-rw-r--r-- | graphics/circuit_macros/examples/svg/BtreeSVG.m4 | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/graphics/circuit_macros/examples/svg/BtreeSVG.m4 b/graphics/circuit_macros/examples/svg/BtreeSVG.m4 new file mode 100644 index 0000000000..df0a2726b2 --- /dev/null +++ b/graphics/circuit_macros/examples/svg/BtreeSVG.m4 @@ -0,0 +1,33 @@ +.PS +# Btree.m4 +# One way to draw a binary tree using pic macros +gen_init(svg_font(sans-serif,11bp__)) +circlerad = 0.35 + +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 |