
echo '***********************************************************************************************************************'
echo '******** script calculating list of non-isomorphic graphs associated to a list of near-facotorizations of a given group'
echo '***********************************************************************************************************************'

if !([ -f ./matcher/matcher ]) 
then 
echo 'the isomorphism test program matcher is not installed as ./matcher/matcher'
echo 'exiting'
exit 1 ;
fi

echo
echo '******** input section  *******************'
echo 'order of the group='
read n < ./tmp/n
echo 'number of the group='
read i < ./tmp/i
echo 'size of A='
read omega < ./tmp/omega

if !([ -f tmp/output.$n.$i ])
then
echo 'there is no list of near-factorization to be processed! Exiting'
exit 1
fi

wc -l < tmp/output.$n.$i > tmp/nblines
read nblines < tmp/nblines
echo 'there are '$nblines' near-factorizations to be processed'

# cleaning up found_graphs directory
rm -f found_graphs/graph.$n.$i.$omega.*
cat tmp/output.$n.$i |
{
if !([ $nblines -eq 0 ]) ; then 
# processing first near-factorization (no isomoprhism test)
line=1
echo 'processing near-factorization number '$line
read string

echo $n > tmp/datas
echo $omega >> tmp/datas
echo $string >> tmp/datas
cat ./groups/group.$n.$i >> tmp/datas
./bin/calculate_associated_graph < tmp/datas > found_graphs/graph.$n.$i.$omega.1
# processing the other near-factorizations
line=2
while [ $line  -le $nblines ] ;
do
echo 'processing near-factorization number '$line
read string
echo $n > tmp/datas
echo $omega >> tmp/datas
echo $string >> tmp/datas
cat ./groups/group.$n.$i >> tmp/datas
./bin/calculate_associated_graph < tmp/datas > tmp/associated_graph
number=1
bool=0
while [ -f found_graphs/graph.$n.$i.$omega.$number ] ;
do
./matcher/matcher tmp/associated_graph found_graphs/graph.$n.$i.$omega.$number 100 > tmp/isomorphism_test_result
./bin/process_output_isomorphism_test < tmp/isomorphism_test_result > tmp/res
read res < tmp/res
if [ $res -eq 1 ] ; then bool=1 ; fi
number=$(($number+1))
done
if [ $bool -eq 0 ] ; then cp tmp/associated_graph found_graphs/graph.$n.$i.$omega.$number ; fi
line=$(($line+1))
done
fi;
}

echo 'over'



 
