#!/bin/sh

# structure $B$N0MB84X78$rD4::$7$F:n?^(B

infile='structures-used.txt'
date=`date +"%y%m%d"`
outfile="dep$date.ps"
#tee="cat"
tee="tee dep$date.dot"
viewer='ggv'

dir=''
dir='rankdir=LR;'

edge=''
#edge='-Edir=back'

node=''
node='-Nfontcolor=blue -Nfontname=Courier-Bold -Nfontsize=14'
#node="$node -Nshape=box"

#structures
#cat $infile; exit

(
echo "digraph Dep {"
echo

# $B8~$-(B
[ $dir ] &&  printf "  $dir\n"

# $BD:E@(B
cat $infile | awk '{printf "  \"%s\";\n", $1;}' | uniq
echo

# $BJU(B
cat $infile | awk '{if ($3) printf "  \"%s\" -> \"%s\";\n", $3, $1;}' | sort | uniq
echo

echo "}"

) | $tee | dot $node $edge -Tps > $outfile

#$viewer $outfile
#rm $outfile
