def main(originalnum,num, superawesomecounter=0):
    stop=False
    force_quit=False
    print originalnum, num, superawesomecounter
    stop=not setupfile(num)
    if not stop:
        g=Graph(labelingConstraints=[2,1])
        with open('C:\\My Dropbox\\GPGlabelings\\graph program 26\\28_3_3#'+str(num)+'.scd','rb') as f:
            nums=readshortcode(f)
            mistercounter=0
            print '00000000',
            for cgraph in g.loadshortcode(nums):
                mistercounter+=1
                superawesomecounter+=1
##                cgraph.quickdraw_to_file()
##                f=file('boo.graph', 'wb')
##                pickle.dump(cgraph,f)
##                f.close()
##                print "autolabeling start:",
                labels=auto_label(cgraph.get_vertices(), cgraph.edges)
##                print '\b\b\b\b\b\bend:',
##                for lcv in xrange(len("autolabeling start:")):
##                    sys.stdout.write('\b')
                if labels!=False:
                    minlabel=5000;
                    maxlabel=-1;
                    for label in labels:
                        if label!="NULL":
                            if label>maxlabel:
                                maxlabel=label
                            if label<minlabel:
                                minlabel=label
                    lnum=maxlabel-minlabel
                    numholes=0
                    for hole in xrange(minlabel+1,maxlabel):
                        if hole not in labels:
                            numholes+=1
                    if lnum>=6 and numholes>=3:
                        adj=str(adjacencymatrix(cgraph.get_vertices(),cgraph.edges))
                        with open('C:\\My Dropbox\\GPGlabelings\\graph program 26\\found'+str(originalnum)+'.txt','a') as res:            
                            res.write(adj)
                        print "WOOOOOOOOOOOOOO:"
                        print adj
                        print num,mistercounter
                        os.system('pause')
                    #print "lambda:"+str(lnum)+" holes:"+str(numholes)
                    sys.stdout.write("\b\b\b\b\b\b\b\b%08d" % mistercounter)
                if kbhit():
                    print '.',
                    if getch()=='q':
                        force_quit=True
                        print "yo imma be the one to end this. to be continued."
            print "completed "+str(mistercounter)+" graphs for "+str(num)
        if os.path.isfile('C:\\My Dropbox\\GPGlabelings\\graph program 26\\28_3_3#'+str(num)+'.scd'):
            os.remove('C:\\My Dropbox\\GPGlabelings\\graph program 26\\28_3_3#'+str(num)+'.scd')
    if not force_quit and kbhit():
        print '.',
        if getch()=='q':
            force_quit=True
            print "yo imma be the one to end this. to be continued."
    if force_quit:
        print "COME BACK NEXT TIME!"
        print superawesomecounter
        os.system('pause')
        sys.exit()
    if num<partition:
        if stop:
            print "no graphs for "+str(num)
##        num=findnumber()
        print "starting next"
##        main(originalnum,num, superawesomecounter)
        return superawesomecounter
    else:
        print "DONE"
        print originalnum, num, partition, superawesomecounter
        os.system('pause')
        sys.exit()
def main(num=4, superawesomecounter=0):
    stop=False
    force_quit=False
    print num, superawesomecounter
    g=Graph(labelingConstraints=[2,1])
    with open('C:\\My Dropbox\\GPGlabelings\\graph program 26\\0rho\\'+'%0*d' % (2,num)+'_4_3.scd','rb') as f:
        nums=readshortcode(num, f)
        mistercounter=0
        print '0000000',
        for cgraph in g.loadshortcode(nums):
            mistercounter+=1
            superawesomecounter+=1
            labels=auto_label(cgraph.get_vertices(), cgraph.edges, [2,1], 8, holes_mode="minimize")
            print "done getting labels"
            #find labels
            if labels!=False:
                minlabel=5000;
                maxlabel=-1;
                for label in labels:
                    if label!="NULL":
                        if label>maxlabel:
                            maxlabel=label
                        if label<minlabel:
                            minlabel=label
                lnum=maxlabel-minlabel

                #find holes                
                numholes=0
                for hole in xrange(minlabel+1,maxlabel):
                    if hole not in labels:
                        numholes+=1

                if numholes > 0:
                    adj=str(adjacencymatrix(cgraph.get_vertices(),cgraph.edges))
                    recordholegraph(num, adj, lnum, numholes)
                if lnum > 8:
                    adj=str(adjacencymatrix(cgraph.get_vertices(),cgraph.edges))
                    recordlargelambdagraph(num, adj, lnum, numholes)
                # test criteria for a 'success'                        
                if lnum > 8 and numholes > 0:
                    adj=str(adjacencymatrix(cgraph.get_vertices(),cgraph.edges))
                    with open('C:\\My Dropbox\\GPGlabelings\\graph program 26\\0rho\\'+str(num)+'found.txt','a') as res:            
                        res.write(adj)
                    print "WOOOOOOOOOOOOOO:"
                    print adj
                    print num,mistercounter
                print "lambda:"+str(lnum)+" holes:"+str(numholes)
                sys.stdout.write("\b\b\b\b\b\b\b%07d" % mistercounter)
            if kbhit():
                print '.',
                if getch()=='q':
                    force_quit=True
                    print "yo imma be the one to end this. to be continued."
            print "completed "+str(mistercounter)+" graphs for "+str(num)
    if not force_quit and kbhit():
        print '.',
        if getch()=='q':
            force_quit=True
            print "yo imma be the one to end this. to be continued."
    if force_quit:
        print "COME BACK NEXT TIME!"
        print superawesomecounter
        os.system('pause')
        sys.exit()

    print "starting next"
    return superawesomecounter