Ejemplo n.º 1
0
def saveFriesFaceFFCC(graph1,graph2,count):

	g1 = graph1.getFaceGraph()
	g2 = graph2.getFaceGraph()

	v1 = makeVertexGraph(g1)
	v2 = makeVertexGraph(g2)

	G1 = Graph(g1,v1)
	G2 = Graph(g2,v2)


	structures1 = assignMatching(G1)
	structures2 = assignMatching(G2)

	Graph.comparison = 'fries'
	structures1.sort()
	structures2.sort()

	h1 = structures1[-1]
	h2 = structures2[-1]

	if not os.path.exists("FFCCConjectureConflicts"):
		os.mkdir("FFCCConjectureConflicts")
	folderName = "FFCCConjectureConflicts/" + str(G1.getNumVertices()) + "_" + str(count)

	#setup folder
	if not os.path.exists(folderName):
		os.mkdir(folderName)
			#print "adding"
	fileName1 = folderName + "/fries1" + ".png"
	fileName2 = folderName + "/fries2" + ".png"
			#print fileName1
	saveSinglePNG(h1,fileName1)
	saveSinglePNG(h2,fileName2)
Ejemplo n.º 2
0
def testConjectureSameFacesFFCC(root, interval):
	clarNumberStructures = []
	friesNumberStructures = []
	graphs = []
	graphList = []

	temp = 0
	graphNumber = 0
	counter = 0

	global Break
	Break = False

	quit = Button(root, text ="Quit", command = BreakModule)
	quit.pack(side = LEFT)

	scrollbar = Scrollbar(root)
	scrollbar.pack(side = RIGHT, fill = Y)

	text = Text(root,yscrollcommand = scrollbar.set)
	text.pack()

	scrollbar.config(command = text.yview)

	timeLimit = 3600 * interval

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

	while t2 - t1 < timeLimit:

		if Break == True:
			Break = False
			quit.destroy()
			break

		text.insert(CURRENT, "Graph " + str(graphNumber) + "\n")

		#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))

			h = structures[-1]

			graphs.append(randomGraph)

			h.setMaxClarManual(setMaxClar(randomGraph))
			h.setMaxFriesManual(setMaxFries(randomGraph))		

			h.setNumStructures(len(structures))
			h.setFaces(getNumFaces(faceGraphToInts(randomFaces)))

			graphCount = 0
			graphNumber += 1

			for g in graphList:

				if(g.getFaces() == h.getFaces()):

					if g.getNumVertices() == h.getNumVertices():

						if g.getNumStructures() < h.getNumStructures():	

							if g.getMaxClar() > h.getMaxClar():

								if g.getMaxFries() < h.getMaxFries():

									print 'Conjecture is false:\n'

									saveClarFaceFFCC(graphs[graphCount],randomGraph,temp)
									saveFriesFaceFFCC(graphs[graphCount],randomGraph,temp)

									folderName = "FFCCConjectureConflicts"

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

									f = open(fileName,'w')							
									f.write("C1: " + str(g.getMaxClar()) + " C2: " + str(h.getMaxClar()) + " F1: " + str(g.getMaxFries()) + " F2: " + str(h.getMaxFries()) + "\n")
									f.write(str(faceGraphToInts(g.getFaceGraph())) + "\n")
									f.write(str(faceGraphToInts(h.getFaceGraph())) + "\n")
									f.close()

									temp += 1
				graphCount += 1
			#only adds graphs to list if it under some number of vertices
			graphList.append(h)
		t2 = time.time()
		counter += 1
Ejemplo n.º 3
0
def testConjectureSameFacesFFCC(hours=0):
	clarNumberStructures = []
	friesNumberStructures = []
	graphs = []
	graphList = []

	temp = 0
	graphNumber = 0

	results = open("results.txt", "w")
	results.write("The program actually run!")

	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))

			h = structures[-1]

			graphs.append(randomGraph)

			h.setMaxClarManual(setMaxClar(randomGraph))
			h.setMaxFriesManual(setMaxFries(randomGraph))		

			h.setNumStructures(len(structures))
			h.setFaces(getNumFaces(faceGraphToInts(randomFaces)))

			graphCount = 0
			graphNumber += 1

			for g in graphList:

				if(g.getFaces() == h.getFaces()):

					if g.getNumVertices() == h.getNumVertices():

						if g.getNumStructures() < h.getNumStructures():	

							if g.getMaxClar() > h.getMaxClar():

								if g.getMaxFries() < h.getMaxFries():

									print 'Conjecture is false:\n'

									saveClarFaceFFCC(graphs[graphCount],randomGraph,temp)
									saveFriesFaceFFCC(graphs[graphCount],randomGraph,temp)

									folderName = "FFCCConjectureConflicts"

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

									f = open(fileName,'w')							
									f.write("C1: " + str(g.getMaxClar()) + " C2: " + str(h.getMaxClar()) + " F1: " + str(g.getMaxFries()) + " F2: " + str(h.getMaxFries()) + "\n")
									f.write(str(faceGraphToInts(g.getFaceGraph())) + "\n")
									f.write(str(faceGraphToInts(h.getFaceGraph())) + "\n")
									f.close()

									temp += 1
				graphCount += 1
			#only adds graphs to list if it under some number of vertices
			graphList.append(h)
		t2 = time.time()
		counter += 1