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


Python graph.Vertex类代码示例

本文整理汇总了Python中graph.Vertex的典型用法代码示例。如果您正苦于以下问题:Python Vertex类的具体用法?Python Vertex怎么用?Python Vertex使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_add_edge_normal

def test_add_edge_normal():
    a = Vertex("A5")
    b = Vertex("A6")
    c = Edge(b)
    a.add_edge(c)
    assert len(a.edges) == 1
    assert c in a.edges
开发者ID:mmweber2,项目名称:adm,代码行数:7,代码来源:test_graph.py

示例2: test_find_path_direct_connection

def test_find_path_direct_connection():
    a = Vertex("A13")
    b = Vertex("A14")
    a.add_edge(Edge(b))
    assert find_path(a, b) == [a, b]
    # Path is only in one direction
    assert find_path(b, a) == []
开发者ID:mmweber2,项目名称:adm,代码行数:7,代码来源:test_graph.py

示例3: test_extra_pipes

def test_extra_pipes():
    name1 = Vertex._make_test_vertex()
    name2 = Vertex._make_test_vertex()
    s = StringIO("2\n{0}\n{1}\n{0}|{1}|5|2\n{1}|{0}|2|5".format(name1, name2))
    g = graph_from_file(s)
    assert g.size() == 2
    assert g.is_connected()
开发者ID:mmweber2,项目名称:adm,代码行数:7,代码来源:test_file_graph.py

示例4: test_valid_with_weights

def test_valid_with_weights():
    name1 = Vertex._make_test_vertex()
    name2 = Vertex._make_test_vertex()
    s = StringIO("2\n{0}\n{1}\n{0}|{1}|5\n{1}|{0}|2".format(name1, name2))
    g = graph_from_file(s)
    assert g.size() == 2
    assert g.is_connected()
开发者ID:mmweber2,项目名称:adm,代码行数:7,代码来源:test_file_graph.py

示例5: test_no_edges

def test_no_edges():
    name1 = Vertex._make_test_vertex()
    name2 = Vertex._make_test_vertex()
    s = StringIO("2\n{}\n{}".format(name1, name2))
    g = graph_from_file(s)
    assert g.size() == 2
    assert not g.is_connected()
开发者ID:mmweber2,项目名称:adm,代码行数:7,代码来源:test_file_graph.py

示例6: test_vertex_valid_edges

def test_vertex_valid_edges():
    """Test Vertex creation with a list of already-existing Edges."""
    b = Vertex(Vertex._make_test_vertex())
    c = Vertex(Vertex._make_test_vertex())
    d = Edge(b)
    e = Edge(c)
    a = Vertex(Vertex._make_test_vertex(), [d, e])
    assert a.edges == [d, e]
开发者ID:mmweber2,项目名称:adm,代码行数:8,代码来源:test_graph.py

示例7: test_add_edge_duplicate

def test_add_edge_duplicate():
    a = Vertex("A7")
    b = Vertex("A8")
    c = Edge(b)
    d = Edge(b)
    a.add_edge(d)
    a.add_edge(c)
    assert len(a.edges) == 2
    assert d in a.edges
    assert c in a.edges
开发者ID:mmweber2,项目名称:adm,代码行数:10,代码来源:test_graph.py

示例8: __init__

 def __init__(self, atomType=None, radicalElectrons=None, spinMultiplicity=None, charge=None, label=''):
     Vertex.__init__(self)
     self.atomType = atomType or []
     for index in range(len(self.atomType)):
         if isinstance(self.atomType[index], str):
             self.atomType[index] = atomTypes[self.atomType[index]]
     self.radicalElectrons = radicalElectrons or []
     self.spinMultiplicity = spinMultiplicity or []
     self.charge = charge or []
     self.label = label
开发者ID:ajalan,项目名称:RMG-Py,代码行数:10,代码来源:group.py

示例9: test_top_sort_chain

def test_top_sort_chain():
    a = Vertex(Vertex._make_test_vertex())
    b = Vertex(Vertex._make_test_vertex())
    c = Vertex(Vertex._make_test_vertex())
    a.add_edge(Edge(b))
    b.add_edge(Edge(c))
    g = Graph([a, b, c])
    assert g.top_sort() == [a, b, c]
开发者ID:mmweber2,项目名称:adm,代码行数:8,代码来源:test_graph.py

示例10: __init__

 def __init__(self, element=None, coord=np.array([0.0, 0.0, 0.0]), radicalElectrons=0, spinMultiplicity=1, implicitHydrogens=0, charge=0, label=''):
     Vertex.__init__(self)
     if isinstance(element, str):
         self.element = elements.__dict__[element]
     else:
         self.element = element
     self.coord = coord
     self.radicalElectrons = radicalElectrons
     self.spinMultiplicity = spinMultiplicity
     self.implicitHydrogens = implicitHydrogens
     self.charge = charge
     self.label = label
     self.atomType = None
开发者ID:chasquiwan,项目名称:RotSpecPy,代码行数:13,代码来源:molecule.py

示例11: test_has_cycle_two_vertices_linked

def test_has_cycle_two_vertices_linked():
    a = Vertex(Vertex._make_test_vertex())
    b = Vertex(Vertex._make_test_vertex())
    a.add_edge(Edge(b))
    b.add_edge(Edge(a))
    g = Graph([a, b])
    assert g.has_cycle()
开发者ID:mmweber2,项目名称:adm,代码行数:7,代码来源:test_graph.py

示例12: test_top_sort_cycle

def test_top_sort_cycle():
    a = Vertex(Vertex._make_test_vertex())
    b = Vertex(Vertex._make_test_vertex())
    a.add_edge(Edge(b))
    b.add_edge(Edge(a))
    g = Graph([a, b])
    assert_raises(ValueError, g.top_sort)
开发者ID:mmweber2,项目名称:adm,代码行数:7,代码来源:test_graph.py

示例13: test_is_connected_two_doubly_connected

def test_is_connected_two_doubly_connected():
    a = Vertex(Vertex._make_test_vertex())
    b = Vertex(Vertex._make_test_vertex())
    a.add_edge(Edge(b))
    b.add_edge(Edge(a))
    g = Graph([a, b])
    assert g.is_connected()
开发者ID:mmweber2,项目名称:adm,代码行数:7,代码来源:test_graph.py

示例14: TestDagShortestPathsModified

 def TestDagShortestPathsModified(self):
     u = Vertex('u')
     v = Vertex('v')
     w = Vertex('w')
     z = Vertex('z')
     u.weight = 1
     v.weight = 2
     w.weight = 3
     z.weight = 4
     vertices = [u, v, w, z]
     edges = [(u, v), (v, w), (v, z)]
     G = Graph(vertices, edges)
     self.assertEquals(dag_shortest_paths_modified(G, u), [u, v, z])
开发者ID:Firkraag,项目名称:algorithm,代码行数:13,代码来源:graph_test.py

示例15: test_find_path_chain

def test_find_path_chain():
    a = Vertex("A15")
    b = Vertex("A16")
    c = Vertex("A17")
    a.add_edge(Edge(b))
    b.add_edge(Edge(c))
    assert find_path(a, c) == [a, b, c]
开发者ID:mmweber2,项目名称:adm,代码行数:7,代码来源:test_graph.py


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