当前位置: 首页>>代码示例>>Python>>正文


Python Graph.getNumVertices方法代码示例

本文整理汇总了Python中Graph.getNumVertices方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.getNumVertices方法的具体用法?Python Graph.getNumVertices怎么用?Python Graph.getNumVertices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graph的用法示例。


在下文中一共展示了Graph.getNumVertices方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: saveFriesFaceFFCC

# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import getNumVertices [as 别名]
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)
开发者ID:Jc11235,项目名称:Kekulean_Program,代码行数:37,代码来源:DriverMethods.py

示例2: testConjectureSameFacesFFCC

# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import getNumVertices [as 别名]
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
#.........这里部分代码省略.........
开发者ID:Jc11235,项目名称:Kekulean_Program,代码行数:103,代码来源:DriverMethods.py

示例3: testConjectureSameFacesFFCC

# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import getNumVertices [as 别名]
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
开发者ID:Jc11235,项目名称:Kekulean_Program,代码行数:94,代码来源:DriverMethods.py


注:本文中的Graph.getNumVertices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。