def test_edges_and_edge_count(self) -> None: g = Graph([(1, 2), (2, 1), (2, 3), (3, 4)]) assert set(g.edges()) == { g.get_edge(1, 2), g.get_edge(2, 3), g.get_edge(3, 4), }, "edges should be (1, 2), (2, 3), (3, 4)" assert g.edge_count == 3, "graph should have 3 edges"
def test_deepcopy(self) -> None: g = Graph([(1, 2, {"color": "blue"}), (3, 4)]) g.add_vertex(42) g_copy = g.deepcopy() assert set(g.vertices()) == set( g_copy.vertices()), "graph copy should have same vertices" assert ( g[1] is not g_copy[1] ), "graph copy vertex objects should be distinct from original graph" assert set(g.edges()) == set( g_copy.edges()), "graph copy should have same edges" assert g.get_edge(1, 2) is not g_copy.get_edge( 1, 2 ), "graph copy edge objects should be distinct from original graph" assert ( g.get_edge(1, 2)._attr == g_copy.get_edge(1, 2)._attr ), "graph copy edge object `_attr` dictionary should contain logically equal contents" assert ( g.get_edge(1, 2)._attr is not g_copy.get_edge(1, 2)._attr ), "graph copy edge object `_attr` dictionary should be distinct from original graph"