예제 #1
0
def clarSubsetDetermination(hours =0):

	temp = 0	
	graphNumber = 0

	if hours == 0:
		interval = float(raw_input("How many hours would you like to run the program? "))
	else:
		interval = hours

	timeLimit = 3600 * interval
	print "limit:", timeLimit

	t1 = time.time()
	t2 = time.time()

	counter = 0
	while t2 - t1 < timeLimit:
		print "graph #" + str(counter)

		#creates a face graphs
		randomFaces = createRandomGraph()
		vertexGraph = []

		#Finds connected graph
		while len(vertexGraph) % 2 != 0 or len(vertexGraph) == 0 or countPeaksAndValleys(randomFaces) == False or isConnected(faceGraphToInts(randomFaces)) == False: 
			randomFaces = createRandomGraph()
			vertexGraph = makeVertexGraph(randomFaces)	

		randomGraph = Graph(randomFaces, vertexGraph)

		perfectMatchingThm = isKekulean(randomGraph)

		if perfectMatchingThm == True:
			structures = assignMatching(randomGraph)

			randomGraph.setMaxClarManual(setMaxClar(randomGraph))
			randomGraph.setMaxFriesManual(setMaxFries(randomGraph))
			
			clarStructure = randomGraph.getMaxClarStructure(structures);
			friesStructure = randomGraph.getMaxFriesStructure(structures);

			clarStructure.setClarFaces();
			friesStructure.setFriesFaces();

			clarFaces = clarStructure.getClarFaces();
			friesFaces = friesStructure.getFriesFaces();

			conjecture = True;

			for f in clarFaces:
				if f.isFries == False:
					conjecture = False;

			if(conjecture == False):

				print 'Conjecture is false'

				foldername = "SubsetConjectureConflicts" 
				
				saveSubsetFaces(foldername,clarStructure,friesStructure,temp)

				folderName = "SubsetConjectureConflicts/" + "_" + str(temp)
				fileName = folderName + "/"  + str(temp)+"_" + "info.txt" 

				f = open(fileName,'w')							
				f.write("C: " + str(randomGraph.getMaxClar()) + " f: " + str(randomGraph.getMaxFries()) +"\n")
			
				f.close()

				temp += 1
			else:
				foldername = "SubsetConjecture" 
				
				saveSubsetFaces(foldername,clarStructure,friesStructure,graphNumber)

				folderName = "SubsetConjecture/" + "_" + str(graphNumber)
				fileName = folderName + "/"  + str(graphNumber)+"_" + "info.txt" 

				f = open(fileName,'w')							
				f.write("C: " + str(randomGraph.getMaxClar()) + " f: " + str(randomGraph.getMaxFries()) +"\n")
			
				f.close()

			#only adds graphs to list if it under some number of vertices
		t2 = time.time()
		counter += 1
		graphNumber +=1
		conjecture = True