#! /bin/bash
# cflow-to-vcg interface.
# Copyright 2002 Junichi Uekawa
# created on 21 June 2002.
# Under GPL version 2 or later.

TF=$(tempfile)
pre=$(tempfile)
post=$(tempfile)

cflow -n  "$@" > "$TF"
(cat $TF | cut  -f1 ; cat $TF | cut -f2) | sort | uniq | sed 's/^\(.*\)$/node: { title: "\1" label: "\1" }/' > "$pre"
cat $TF | sort | sed 's/^\([^	]*\)	\([^	]*\).*$/edge: { sourcename: "\1" targetname: "\2" class: 2}/' > "$post"

cat <<EOF
graph: { title: "$@"
xmax: 700 ymax: 700 x: 30 y: 30
layout_downfactor: 8
EOF

cat "$pre" "$post"  
cat <<EOF
}
EOF

