Ejemplo n.º 1
0
def test_graph_add_vertices():
    G = Graph([1, 2, 3], [(1, 2), (2, 3)])
    G.add_vertices(4)
    assert str(G) == "Graph on 4 vertices and 2 edges"
    G.add_vertices(5, labels={5: Text("5")})
    assert str(G) == "Graph on 5 vertices and 2 edges"
    assert 5 in G._labels
    assert 5 in G._vertex_config
    G.add_vertices(6, 7, 8)
    assert len(G.vertices) == 8
    assert len(G._graph.nodes()) == 8
Ejemplo n.º 2
0
def test_graph_add_vertices(using_opengl_renderer):
    G = Graph([1, 2, 3], [(1, 2), (2, 3)])
    G.add_vertices(4)
    assert len(G.vertices) == 4
    assert len(G.edges) == 2
    G.add_vertices(5, labels={5: Text("5")})
    assert len(G.vertices) == 5
    assert len(G.edges) == 2
    assert 5 in G._labels
    assert 5 in G._vertex_config
    G.add_vertices(6, 7, 8)
    assert len(G.vertices) == 8
    assert len(G._graph.nodes()) == 8
Ejemplo n.º 3
0
 def construct(self):
     G = Graph([], [], labels=True)
     G.scale(0.45)
     G.add_vertices(1, positions={1: [0, 0, 0]}, labels=True)
     self.play(Create(G))
     self.wait(10)