def test_write_read_p2g(self): fh = io.BytesIO() G = nx.DiGraph() G.name = "foo" G.add_edges_from([("a", "b"), ("b", "c")]) write_p2g(G, fh) fh.seek(0) H = read_p2g(fh) assert edges_equal(G.edges(), H.edges())
def test_write_read_p2g(self): fh = io.BytesIO() G = nx.DiGraph() G.name = 'foo' G.add_edges_from([('a', 'b'), ('b', 'c')]) write_p2g(G, fh) fh.seek(0) H = read_p2g(fh) assert_edges_equal(G.edges(), H.edges())
def test_read_p2g(self): s = b"""\ name 3 4 a 1 2 b c 0 2 """ bytesIO = io.BytesIO(s) G = read_p2g(bytesIO) assert G.name == 'name' assert sorted(G) == ['a', 'b', 'c'] edges = [(str(u), str(v)) for u, v in G.edges()] assert_edges_equal(G.edges(), [('a', 'c'), ('a', 'b'), ('c', 'a'), ('c', 'c')])
def test_read_p2g(self): s = b"""\ name 3 4 a 1 2 b c 0 2 """ bytesIO = io.BytesIO(s) G = read_p2g(bytesIO) assert G.name == "name" assert sorted(G) == ["a", "b", "c"] edges = [(str(u), str(v)) for u, v in G.edges()] assert edges_equal(G.edges(), [("a", "c"), ("a", "b"), ("c", "a"), ("c", "c")])