本文整理匯總了Python中rmgpy.molecule.graph.Graph.resetConnectivityValues方法的典型用法代碼示例。如果您正苦於以下問題:Python Graph.resetConnectivityValues方法的具體用法?Python Graph.resetConnectivityValues怎麽用?Python Graph.resetConnectivityValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rmgpy.molecule.graph.Graph
的用法示例。
在下文中一共展示了Graph.resetConnectivityValues方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestGraph
# 需要導入模塊: from rmgpy.molecule.graph import Graph [as 別名]
# 或者: from rmgpy.molecule.graph.Graph import resetConnectivityValues [as 別名]
#.........這裏部分代碼省略.........
is being done.
"""
vertices1 = [Vertex() for i in range(4)]
edges1 = [Edge(vertices1[0], vertices1[1]), Edge(vertices1[1], vertices1[2]), Edge(vertices1[2], vertices1[3])]
vertices2 = [Vertex() for i in range(3)]
edges2 = [Edge(vertices2[0], vertices2[1]), Edge(vertices2[1], vertices2[2])]
graph1 = Graph()
for vertex in vertices1:
graph1.addVertex(vertex)
for edge in edges1:
graph1.addEdge(edge)
graph2 = Graph()
for vertex in vertices2:
graph2.addVertex(vertex)
for edge in edges2:
graph2.addEdge(edge)
graph = graph1.merge(graph2)
self.assertTrue(len(graph1.vertices) + len(graph2.vertices) == len(graph.vertices))
for vertex1 in vertices1:
self.assertTrue(vertex1 in graph.vertices)
for vertex2 in vertex1.edges:
self.assertTrue(vertex2 in graph.vertices)
for vertex2 in vertices2:
self.assertTrue(vertex2 in graph.vertices)
for vertex1 in vertex2.edges:
self.assertTrue(vertex1 in vertex2.edges)
def test_resetConnectivityValues(self):
"""
Test the Graph.resetConnectivityValues() method.
"""
self.graph.resetConnectivityValues()
for vertex in self.graph.vertices:
self.assertEqual(vertex.connectivity, -1)
self.assertEqual(vertex.sortingLabel, -1)
def test_updateConnectivityValues(self):
"""
Test the Graph.updateConnectivityValues() method.
"""
self.graph.updateConnectivityValues()
self.assertEqual(self.graph.vertices[0].connectivity, 10)
self.assertEqual(self.graph.vertices[0].sortingLabel, -1)
self.assertEqual(self.graph.vertices[1].connectivity, 19)
self.assertEqual(self.graph.vertices[1].sortingLabel, -1)
self.assertEqual(self.graph.vertices[2].connectivity, 23)
self.assertEqual(self.graph.vertices[2].sortingLabel, -1)
self.assertEqual(self.graph.vertices[3].connectivity, 23)
self.assertEqual(self.graph.vertices[3].sortingLabel, -1)
self.assertEqual(self.graph.vertices[4].connectivity, 19)
self.assertEqual(self.graph.vertices[4].sortingLabel, -1)
self.assertEqual(self.graph.vertices[5].connectivity, 10)
self.assertEqual(self.graph.vertices[5].sortingLabel, -1)
def test_sortVertices(self):
"""
Test the Graph.sortVertices() method.
"""
self.graph.updateConnectivityValues()
self.graph.sortVertices()
示例2: TestGraph
# 需要導入模塊: from rmgpy.molecule.graph import Graph [as 別名]
# 或者: from rmgpy.molecule.graph.Graph import resetConnectivityValues [as 別名]
#.........這裏部分代碼省略.........
vertices1 = [Vertex() for i in range(4)]
edges1 = [
Edge(vertices1[0], vertices1[1]),
Edge(vertices1[1], vertices1[2]),
Edge(vertices1[2], vertices1[3]),
]
vertices2 = [Vertex() for i in range(3)]
edges2 = [
Edge(vertices2[0], vertices2[1]),
Edge(vertices2[1], vertices2[2]),
]
graph1 = Graph()
for vertex in vertices1: graph1.addVertex(vertex)
for edge in edges1: graph1.addEdge(edge)
graph2 = Graph()
for vertex in vertices2: graph2.addVertex(vertex)
for edge in edges2: graph2.addEdge(edge)
graph = graph1.merge(graph2)
self.assertTrue(len(graph1.vertices) + len(graph2.vertices) == len(graph.vertices))
for vertex1 in vertices1:
self.assertTrue(vertex1 in graph.vertices)
for vertex2 in vertex1.edges:
self.assertTrue(vertex2 in graph.vertices)
for vertex2 in vertices2:
self.assertTrue(vertex2 in graph.vertices)
for vertex1 in vertex2.edges:
self.assertTrue(vertex1 in vertex2.edges)
def test_resetConnectivityValues(self):
"""
Test the Graph.resetConnectivityValues() method.
"""
self.graph.resetConnectivityValues()
for vertex in self.graph.vertices:
self.assertEqual(vertex.connectivity1, -1)
self.assertEqual(vertex.connectivity2, -1)
self.assertEqual(vertex.connectivity3, -1)
self.assertEqual(vertex.sortingLabel, -1)
def test_updateConnectivityValues(self):
"""
Test the Graph.updateConnectivityValues() method.
"""
self.graph.updateConnectivityValues()
self.assertEqual(self.graph.vertices[0].connectivity1, 1)
self.assertEqual(self.graph.vertices[0].connectivity2, 2)
self.assertEqual(self.graph.vertices[0].connectivity3, 3)
self.assertEqual(self.graph.vertices[0].sortingLabel, -1)
self.assertEqual(self.graph.vertices[1].connectivity1, 2)
self.assertEqual(self.graph.vertices[1].connectivity2, 3)
self.assertEqual(self.graph.vertices[1].connectivity3, 6)
self.assertEqual(self.graph.vertices[1].sortingLabel, -1)
self.assertEqual(self.graph.vertices[2].connectivity1, 2)
self.assertEqual(self.graph.vertices[2].connectivity2, 4)
self.assertEqual(self.graph.vertices[2].connectivity3, 7)
self.assertEqual(self.graph.vertices[2].sortingLabel, -1)
self.assertEqual(self.graph.vertices[3].connectivity1, 2)
self.assertEqual(self.graph.vertices[3].connectivity2, 4)
self.assertEqual(self.graph.vertices[3].connectivity3, 7)
self.assertEqual(self.graph.vertices[3].sortingLabel, -1)
self.assertEqual(self.graph.vertices[4].connectivity1, 2)
示例3: TestGraph
# 需要導入模塊: from rmgpy.molecule.graph import Graph [as 別名]
# 或者: from rmgpy.molecule.graph.Graph import resetConnectivityValues [as 別名]
#.........這裏部分代碼省略.........
vertices1 = [Vertex() for i in range(4)]
edges1 = [
Edge(vertices1[0], vertices1[1]),
Edge(vertices1[1], vertices1[2]),
Edge(vertices1[2], vertices1[3]),
]
vertices2 = [Vertex() for i in range(3)]
edges2 = [
Edge(vertices2[0], vertices2[1]),
Edge(vertices2[1], vertices2[2]),
]
graph1 = Graph()
for vertex in vertices1: graph1.addVertex(vertex)
for edge in edges1: graph1.addEdge(edge)
graph2 = Graph()
for vertex in vertices2: graph2.addVertex(vertex)
for edge in edges2: graph2.addEdge(edge)
graph = graph1.merge(graph2)
self.assertTrue(len(graph1.vertices) + len(graph2.vertices) == len(graph.vertices))
for vertex1 in vertices1:
self.assertTrue(vertex1 in graph.vertices)
for vertex2 in vertex1.edges:
self.assertTrue(vertex2 in graph.vertices)
for vertex2 in vertices2:
self.assertTrue(vertex2 in graph.vertices)
for vertex1 in vertex2.edges:
self.assertTrue(vertex1 in vertex2.edges)
def test_resetConnectivityValues(self):
"""
Test the Graph.resetConnectivityValues() method.
"""
self.graph.resetConnectivityValues()
for vertex in self.graph.vertices:
self.assertEqual(vertex.connectivity1, -1)
self.assertEqual(vertex.connectivity2, -1)
self.assertEqual(vertex.connectivity3, -1)
self.assertEqual(vertex.sortingLabel, -1)
def test_updateConnectivityValues(self):
"""
Test the Graph.updateConnectivityValues() method.
"""
self.graph.updateConnectivityValues()
self.assertEqual(self.graph.vertices[0].connectivity1, 1)
self.assertEqual(self.graph.vertices[0].connectivity2, 2)
self.assertEqual(self.graph.vertices[0].connectivity3, 3)
self.assertEqual(self.graph.vertices[0].sortingLabel, -1)
self.assertEqual(self.graph.vertices[1].connectivity1, 2)
self.assertEqual(self.graph.vertices[1].connectivity2, 3)
self.assertEqual(self.graph.vertices[1].connectivity3, 6)
self.assertEqual(self.graph.vertices[1].sortingLabel, -1)
self.assertEqual(self.graph.vertices[2].connectivity1, 2)
self.assertEqual(self.graph.vertices[2].connectivity2, 4)
self.assertEqual(self.graph.vertices[2].connectivity3, 7)
self.assertEqual(self.graph.vertices[2].sortingLabel, -1)
self.assertEqual(self.graph.vertices[3].connectivity1, 2)
self.assertEqual(self.graph.vertices[3].connectivity2, 4)
self.assertEqual(self.graph.vertices[3].connectivity3, 7)
self.assertEqual(self.graph.vertices[3].sortingLabel, -1)
self.assertEqual(self.graph.vertices[4].connectivity1, 2)