# Usage: python makeCliques.py (outputfilename) (size1) (size2) ...

import sys
import numpy
import random

numcliques = len(sys.argv) - 2
cliquesizes = []
for i in range(2, 2+numcliques):
   cliquesizes.append(int(sys.argv[i]))

n = sum(cliquesizes)

ADJ = numpy.zeros([n,n])

currnode = 0
for cliquesize in cliquesizes:
   for j in range(currnode, currnode+cliquesize):
      for k in range(j+1, currnode+cliquesize):
         ADJ[j][k] = random.random()   #0 to 1   
   currnode += cliquesize

gmlfile = open(sys.argv[1], 'w')
gmlfile.write("graph [\n")
for i in range(n):
   gmlfile.write("node [\n")
   gmlfile.write("id "+str(i)+"\n")
   gmlfile.write("label \"A"+str(i)+"\"\n")
   gmlfile.write("]\n")
for i in range(n):
   for j in range(i+1, n):
    if (ADJ[i][j] != 0):
      gmlfile.write("edge [\n")
      gmlfile.write("source "+str(i)+"\n")
      gmlfile.write("target "+str(j)+"\n")
      gmlfile.write("weight "+str(ADJ[i][j])+"\n")
      gmlfile.write("]\n")
gmlfile.write("]\n")
