本文整理匯總了Python中rmgpy.molecule.graph.Graph.isEdgeInCycle方法的典型用法代碼示例。如果您正苦於以下問題:Python Graph.isEdgeInCycle方法的具體用法?Python Graph.isEdgeInCycle怎麽用?Python Graph.isEdgeInCycle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rmgpy.molecule.graph.Graph
的用法示例。
在下文中一共展示了Graph.isEdgeInCycle方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestGraph
# 需要導入模塊: from rmgpy.molecule.graph import Graph [as 別名]
# 或者: from rmgpy.molecule.graph.Graph import isEdgeInCycle [as 別名]
#.........這裏部分代碼省略.........
import cPickle
graph = cPickle.loads(cPickle.dumps(graph0))
self.assertEqual(len(graph0.vertices), len(graph.vertices))
for v1, v2 in zip(graph0.vertices, graph.vertices):
self.assertEqual(v1.connectivity, v2.connectivity)
self.assertEqual(v1.sortingLabel, v2.sortingLabel)
self.assertEqual(len(v1.edges), len(v2.edges))
self.assertTrue(graph0.isIsomorphic(graph))
self.assertTrue(graph.isIsomorphic(graph0))
def test_isCyclic(self):
"""
Test the Graph.isCyclic() method.
"""
self.assertFalse(self.graph.isCyclic())
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle
self.assertTrue(self.graph.isCyclic())
def test_isVertexInCycle(self):
"""
Test the Graph.isVertexInCycle() method.
"""
for vertex in self.graph.vertices:
self.assertFalse(self.graph.isVertexInCycle(vertex))
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle
for vertex in self.graph.vertices[0:4]:
self.assertTrue(self.graph.isVertexInCycle(vertex))
for vertex in self.graph.vertices[4:]:
self.assertFalse(self.graph.isVertexInCycle(vertex))
def test_isEdgeInCycle(self):
"""
Test the Graph.isEdgeInCycle() method.
"""
for vertex1 in self.graph.vertices:
for vertex2, edge in vertex1.edges.items():
self.assertFalse(self.graph.isEdgeInCycle(edge))
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle
for vertex1 in self.graph.vertices:
for vertex2, edge in vertex1.edges.items():
if self.graph.vertices.index(vertex1) < 4 and self.graph.vertices.index(vertex2) < 4:
self.assertTrue(self.graph.isEdgeInCycle(edge))
else:
self.assertFalse(self.graph.isEdgeInCycle(edge))
def test_getAllCyclicVertices(self):
self.assertListEqual(self.graph.getAllCyclicVertices(), [])
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle
self.assertEqual(len(self.graph.getAllCyclicVertices()), 4)
def test_getAllPolycylicVertices(self):
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle
self.assertListEqual(self.graph.getAllPolycyclicVertices(), [])
edge2 = Edge(self.graph.vertices[0], self.graph.vertices[5])
self.graph.addEdge(edge2) # Create another cycle to generate two fused cycles
self.assertEqual(len(self.graph.getAllPolycyclicVertices()), 2)
# Add new vertices and edges to generate a spirocyclic cycle
vertices = [Vertex() for i in range(2)]
for vertex in vertices:
self.graph.addVertex(vertex)
edges = [
Edge(self.graph.vertices[5], self.graph.vertices[6]),
Edge(self.graph.vertices[6], self.graph.vertices[7]),
Edge(self.graph.vertices[5], self.graph.vertices[7]),
]
for edge in edges:
self.graph.addEdge(edge)
self.assertEqual(len(self.graph.getAllPolycyclicVertices()), 3)
def test_getAllCycles(self):
"""
Test the Graph.getAllCycles() method.
"""
cycleList = self.graph.getAllCycles(self.graph.vertices[0])
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.getAllCycles(self.graph.vertices[0])
self.assertEqual(len(cycleList), 2)
self.assertEqual(len(cycleList[0]), 4)
self.assertEqual(len(cycleList[1]), 4)
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)
示例2: TestGraph
# 需要導入模塊: from rmgpy.molecule.graph import Graph [as 別名]
# 或者: from rmgpy.molecule.graph.Graph import isEdgeInCycle [as 別名]
#.........這裏部分代碼省略.........
self.assertEqual(len(graph0.vertices), len(graph.vertices))
for v1, v2 in zip(graph0.vertices, graph.vertices):
self.assertEqual(v1.connectivity1, v2.connectivity1)
self.assertEqual(v1.connectivity2, v2.connectivity2)
self.assertEqual(v1.connectivity3, v2.connectivity3)
self.assertEqual(v1.sortingLabel, v2.sortingLabel)
self.assertEqual(len(v1.edges), len(v2.edges))
self.assertTrue(graph0.isIsomorphic(graph))
self.assertTrue(graph.isIsomorphic(graph0))
def test_isCyclic(self):
"""
Test the Graph.isCyclic() method.
"""
self.assertFalse(self.graph.isCyclic())
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle
self.assertTrue(self.graph.isCyclic())
def test_isVertexInCycle(self):
"""
Test the Graph.isVertexInCycle() method.
"""
for vertex in self.graph.vertices:
self.assertFalse(self.graph.isVertexInCycle(vertex))
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle
for vertex in self.graph.vertices[0:4]:
self.assertTrue(self.graph.isVertexInCycle(vertex))
for vertex in self.graph.vertices[4:]:
self.assertFalse(self.graph.isVertexInCycle(vertex))
def test_isEdgeInCycle(self):
"""
Test the Graph.isEdgeInCycle() method.
"""
for vertex1 in self.graph.vertices:
for vertex2, edge in vertex1.edges.items():
self.assertFalse(self.graph.isEdgeInCycle(edge))
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle
for vertex1 in self.graph.vertices:
for vertex2, edge in vertex1.edges.items():
if self.graph.vertices.index(vertex1) < 4 and self.graph.vertices.index(vertex2) < 4:
self.assertTrue(self.graph.isEdgeInCycle(edge))
else:
self.assertFalse(self.graph.isEdgeInCycle(edge))
def test_getAllCyclicVertices(self):
self.assertListEqual(self.graph.getAllCyclicVertices(), [])
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle
self.assertEqual(len(self.graph.getAllCyclicVertices()), 4)
def test_getAllPolycylicVertices(self):
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle
self.assertListEqual(self.graph.getAllPolycyclicVertices(), [])
edge2 = Edge(self.graph.vertices[0], self.graph.vertices[5])
self.graph.addEdge(edge2) # Create another cycle to generate two fused cycles
self.assertEqual(len(self.graph.getAllPolycyclicVertices()), 2)
# Add new vertices and edges to generate a spirocyclic cycle
vertices = [Vertex() for i in range(2)]
for vertex in vertices: self.graph.addVertex(vertex)
edges = [
示例3: TestGraph
# 需要導入模塊: from rmgpy.molecule.graph import Graph [as 別名]
# 或者: from rmgpy.molecule.graph.Graph import isEdgeInCycle [as 別名]
#.........這裏部分代碼省略.........
self.assertEqual(len(graph0.vertices), len(graph.vertices))
for v1, v2 in zip(graph0.vertices, graph.vertices):
self.assertEqual(v1.connectivity1, v2.connectivity1)
self.assertEqual(v1.connectivity2, v2.connectivity2)
self.assertEqual(v1.connectivity3, v2.connectivity3)
self.assertEqual(v1.sortingLabel, v2.sortingLabel)
self.assertEqual(len(v1.edges), len(v2.edges))
self.assertTrue(graph0.isIsomorphic(graph))
self.assertTrue(graph.isIsomorphic(graph0))
def test_isCyclic(self):
"""
Test the Graph.isCyclic() method.
"""
self.assertFalse(self.graph.isCyclic())
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle
self.assertTrue(self.graph.isCyclic())
def test_isVertexInCycle(self):
"""
Test the Graph.isVertexInCycle() method.
"""
for vertex in self.graph.vertices:
self.assertFalse(self.graph.isVertexInCycle(vertex))
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle
for vertex in self.graph.vertices[0:4]:
self.assertTrue(self.graph.isVertexInCycle(vertex))
for vertex in self.graph.vertices[4:]:
self.assertFalse(self.graph.isVertexInCycle(vertex))
def test_isEdgeInCycle(self):
"""
Test the Graph.isEdgeInCycle() method.
"""
for vertex1 in self.graph.vertices:
for vertex2, edge in vertex1.edges.items():
self.assertFalse(self.graph.isEdgeInCycle(edge))
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle
for vertex1 in self.graph.vertices:
for vertex2, edge in vertex1.edges.items():
if self.graph.vertices.index(vertex1) < 4 and self.graph.vertices.index(vertex2) < 4:
self.assertTrue(self.graph.isEdgeInCycle(edge))
else:
self.assertFalse(self.graph.isEdgeInCycle(edge))
def test_getAllCyclicVertices(self):
self.assertListEqual(self.graph.getAllCyclicVertices(), [])
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle
self.assertEqual(len(self.graph.getAllCyclicVertices()), 4)
def test_getAllPolycylicVertices(self):
edge = Edge(self.graph.vertices[0], self.graph.vertices[3])
self.graph.addEdge(edge) # To create a cycle
self.assertListEqual(self.graph.getAllPolycyclicVertices(), [])
edge2 = Edge(self.graph.vertices[0], self.graph.vertices[5])
self.graph.addEdge(edge2) # Create another cycle to generate two fused cycles
self.assertEqual(len(self.graph.getAllPolycyclicVertices()), 2)
# Add new vertices and edges to generate a spirocyclic cycle
vertices = [Vertex() for i in range(2)]
for vertex in vertices: self.graph.addVertex(vertex)
edges = [