本文整理匯總了Python中rmgpy.molecule.graph.Graph.getRelevantCycles方法的典型用法代碼示例。如果您正苦於以下問題:Python Graph.getRelevantCycles方法的具體用法?Python Graph.getRelevantCycles怎麽用?Python Graph.getRelevantCycles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rmgpy.molecule.graph.Graph
的用法示例。
在下文中一共展示了Graph.getRelevantCycles方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestGraph
# 需要導入模塊: from rmgpy.molecule.graph import Graph [as 別名]
# 或者: from rmgpy.molecule.graph.Graph import getRelevantCycles [as 別名]
#.........這裏部分代碼省略.........
self.assertEqual(len(cycleList), 2)
self.assertEqual(len(cycleList[0]), 4)
self.assertEqual(len(cycleList[1]), 4)
def test_getAllSimpleCyclesOfSize(self):
"""
Test the Graph.getAllSimpleCyclesOfSize() method.
"""
cycleList = self.graph.getAllCyclesOfSize(6)
self.assertEqual(len(cycleList), 0)
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle of length 4
edge = Edge(self.graph.vertices[0], self.graph.vertices[5])
self.graph.addEdge(edge) # To create a cycle of length 6 and another cycle of length 4
cycleList = self.graph.getAllSimpleCyclesOfSize(4)
self.assertEqual(len(cycleList), 2)
self.assertEqual(len(cycleList[0]), 4)
self.assertEqual(len(cycleList[1]), 4)
cycleList = self.graph.getAllSimpleCyclesOfSize(6)
self.assertEqual(len(cycleList), 0)
def test_getSmallestSetOfSmallestRings(self):
"""
Test the Graph.getSmallestSetOfSmallestRings() method.
"""
cycleList = self.graph.getSmallestSetOfSmallestRings()
self.assertEqual(len(cycleList), 0)
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle
cycleList = self.graph.getSmallestSetOfSmallestRings()
self.assertEqual(len(cycleList), 1)
self.assertEqual(len(cycleList[0]), 4)
def test_getRelevantCycles(self):
"""
Test the Graph.getRelevantCycles() method.
"""
cycleList = self.graph.getRelevantCycles()
self.assertEqual(len(cycleList), 0)
# Create a cycle of length 4
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge)
# Create a second cycle of length 4
edge = Edge(self.graph.vertices[0], self.graph.vertices[5])
self.graph.addEdge(edge)
# Create a bridge forming multiple cycles of length 4
edge = Edge(self.graph.vertices[1], self.graph.vertices[4])
self.graph.addEdge(edge)
# SSSR should be 3 cycles of length 4
cycleList = self.graph.getSmallestSetOfSmallestRings()
self.assertEqual(len(cycleList), 3)
sizeList = sorted([len(cycle) for cycle in cycleList])
self.assertEqual(sizeList, [4, 4, 4])
# RC should be 5 cycles of length 4
cycleList = self.graph.getRelevantCycles()
self.assertEqual(len(cycleList), 5)
sizeList = sorted([len(cycle) for cycle in cycleList])
self.assertEqual(sizeList, [4, 4, 4, 4, 4])
def test_cycleListOrderSSSR(self):
"""
Test that getSmallestSetOfSmallestRings return vertices in the proper order.
There are methods such as symmetry and molecule drawing which rely