本文整理匯總了Python中rmgpy.molecule.graph.Graph.merge方法的典型用法代碼示例。如果您正苦於以下問題:Python Graph.merge方法的具體用法?Python Graph.merge怎麽用?Python Graph.merge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rmgpy.molecule.graph.Graph
的用法示例。
在下文中一共展示了Graph.merge方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_merge
# 需要導入模塊: from rmgpy.molecule.graph import Graph [as 別名]
# 或者: from rmgpy.molecule.graph.Graph import merge [as 別名]
def test_merge(self):
"""
Test the graph merge function to ensure a proper merging of the graph
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)