#!/bin/bash

###############################################################################################
#	Advanced RTI System, ARTÌS			http://pads.cs.unibo.it
#	Large Unstructured NEtwork Simulator (LUNES)
#
#	make-corpus
#		version: 	0.1	14/12/10
#
#		original author:	Gabriele D'Angelo	<gda@cs.unibo.it>
#
#	description:
#
#	usage:	
#		./make-corpus <#NODES> <#EDGES> <MAX_DIAMETER>
#		mandatory input parameters = #NODES
#		<#NODES>		number of nodes in the networks to be generated
#		<#EDGES>		number of edges for each node		
#		<MAX_DIAMETER>		max diameter of the generated graphs
#
#		example: ./make-corpus 100 2 8
#			generate a corpus (NUMBERRUNS) graphs each one composed
#			of 100 nodes, each node will have 2 edges, and each graph will 
#			have a diameter less or equal to 8
#
###########################################################################################

#
# Including some default configuration parameters
#
source scripts_configuration.sh

RUN=$NUMBERRUNS
TOT_RUNS=$RUN

if [ "$#" != "3" ]; then
        echo "		  Incorrect syntax...		 "
        echo "USAGE: $0 [#NODES] [#EDGES] [MAX_DIAMETER]"
        echo ""
        exit
fi

EDGES=$(($2*$1))

# Creating the corpus of graphs
while [ $RUN -gt 0 ]
do
	echo "Generating the graph: " $RUN "of" $TOT_RUNS
	./graphgen $1 $EDGES "$CORPUS_DIRECTORY/test-graph-$RUN.dot" $3
	cat "$CORPUS_DIRECTORY/test-graph-$RUN.dot" | grep "\-\-" > "$CORPUS_DIRECTORY/test-graph-cleaned-$RUN.dot"

	# The random generator used by igraph is very stupid, the seed is taken from the current time
	sleep 1
        RUN=$((RUN-1))
done
