#!/bin/bash
#
# kngraph.sh
# http://freaknet.org/alpt/src/misc/kngraph.sh
#
# --
# Generates a Complete Graph
#
# This script depends on Graphviz: http://www.graphviz.org/
#
# AlpT (@freaknet.org)
#


if [ -z "$1" ]
then
	echo "Specify the number of nodes"
	echo "	./kngraph.sh 10"
	exit 1
fi

K=$1

echo Writing k$K.dot
awk "BEGIN { print \"graph G {\"
	     print \"node [color=red, shape=circle, label=\\\"\\\",\" \\
	     \"height=0.1, width=0.1, style=filled]\"
	     for(i=1; i<=$K;i++){for(o=i+1;o<=$K;o++){
		     if(i==o)continue; 
		     print \"e\" i \" -- \" \"e\"o;
	     }}
	     print \"}\"}" > k$K.dot


echo "Executing 'circo -Tsvg k$K.dot > k$K.svg'"
circo -Tsvg k$K.dot > k$K.svg
