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


Python Graph.getFaceGraph方法代码示例

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


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

示例1: checkConnected

# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import getFaceGraph [as 别名]
def checkConnected(d, g):

	totalFaceCount = getNumFaces(g)
	queue = []

	#make faceGraph
	faceGraph = []
	y = 0
	while y < len(g):
		row = g[y]		
		for x in row:
			faceGraph.append((Face(int(x), y)))
		y += 1

	vg = makeVertexGraph(faceGraph)
	graph = Graph(faceGraph, vg)
		
	queue.append(graph.getFaceGraph()[0])
	visited = set()

	while len(visited) < len(graph.getFaceGraph()):
		face = queue.pop(0)
		while face in visited:
			#print "in while"
			if len(queue) > 0:
				face = queue.pop(0)
			else:
				break
		#this means that the face is visited and grpah is disconnected	
		if face in visited:
			break

		nextGroup = face.getNeighbors()
		if len(nextGroup) == 0:
			break
		else:
			queue.extend(nextGroup)

		#print "stats"
		#print len(graph.getFaceGraph()), len(queue), len(visited)
		visited.add(face)

		#print "graph"
		#print graph
		#print "-------------------"
	return len(graph.getFaceGraph()) == len(visited)
开发者ID:MCLA-Cheminformatics,项目名称:Kekulean,代码行数:48,代码来源:Checkers.py

示例2: testConjectureDifferentFaces

# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import getFaceGraph [as 别名]
def testConjectureDifferentFaces(hours=0):
	graphList = []
	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)

			for f in randomGraph.getFaceGraph():
				pairs = randomGraph.getBondedVertices(f)
				print str(pairs)
			
			#must be 'fries' or 'clars'
			Graph.comparison = 'clars'
			structures.sort()

			h = structures[-1]
			h.setNumStructures(len(structures))
			#h.setString(structures[0].simpleToString())

			#is the data right?
			#print "Verts:", h.getNumVertices()
			#print "Structures:", h.getNumStructures()
			#print "Clar:", h.getFriesNumber()

			for g in graphList:
				if h.getNumVertices() == g.getNumVertices() :#and h.getNumVertices() <= 26:
					if h.getNumStructures() < g.getNumStructures():

#first part
						if h.getClarsNumber() > g.getClarsNumber():
							print 'Conjecture is false:'
								
							results.write('\ngraph H: Clars: ' + str(h.getClarsNumber()) + " Number of Structures: " + str(h.getNumStructures()) + " Number of vertices: " + str(h.getNumVertices()) + "\n") 
							results.write(str(h))
							results.write('\ngraph G: Clars: ' + str(g.getClarsNumber()) + " Number of Structures: " + str(g.getNumStructures()) + " Number of vertices: " + str(g.getNumVertices()) + "\n") 
							results.write(str(g))
							results.write("\n\n")

							drawConflictsCC(g, h)
#second part

						if h.getFriesNumber() > g.getFriesNumber():
							print 'Conjecture is false:'
							results.write('\ngraph H: Fries: ' + str(h.getFriesNumber()) + " Number of Structures: " + str(h.getNumStructures()) + " Number of vertices: " + str(h.getNumVertices()) + "\n") 
							results.write(str(h))
							results.write('\ngraph G: Fries: ' + str(g.getFriesNumber()) + " Number of Structures: " + str(g.getNumStructures()) + " Number of vertices: " + str(g.getNumVertices()) + "\n") 
							results.write(str(g))
							results.write("\n\n")
	
							drawConflictsKKFF(g, h)
#third part
						if h.getClarsNumber() > g.getClarsNumber():  
							if h.getFriesNumber() < g.getFriesNumber():
								print 'Conjecture is false:'
								results.write('\ngraph H: Clars: ' + str(h.getClarsNumber()) + "graph H: Fries: " + str(h.getFriesNumber()) + " Number of Structures: " + str(h.getNumStructures()) + " Number of vertices: " + str(h.getNumVertices()) + "\n") 
								results.write(str(h))
								results.write('\ngraph G: Clars: ' + str(g.getClarsNumber()) + "graph G: Fries: " + str(g.getFriesNumber()) +" Number of Structures: " + str(g.getNumStructures()) + " Number of vertices: " + str(g.getNumVertices()) + "\n") 
								results.write(str(g))
								results.write("\n\n")

								drawConflictsFFCC(g, h)

			#only adds graphs to list if it under some number of vertices
			graphList.append(h)

		t2 = time.time()
		counter += 1
开发者ID:Jc11235,项目名称:Kekulean_Program,代码行数:98,代码来源:DriverMethods.py


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