def test_write_undirected(self): G = zen.Graph() G.add_nodes(5) G.add_edge_(0,1) G.add_edge_(1,2) G.add_edge_(3,4) fd,fname = tempfile.mkstemp() os.close(fd) memlist.write(G,fname) G2 = memlist.read(fname,directed=False) self.assertEqual(len(G2),len(G)) self.assertEqual(G2.size(),G.size())
def test_write_undirected(self): G = zen.Graph() G.add_nodes(5) G.add_edge_(0, 1) G.add_edge_(1, 2) G.add_edge_(3, 4) fd, fname = tempfile.mkstemp() os.close(fd) memlist.write(G, fname) G2 = memlist.read(fname, directed=False) self.assertEqual(len(G2), len(G)) self.assertEqual(G2.size(), G.size())
def test_write_compact_undirected(self): G = zen.Graph() G.add_nodes(5) e1 = G.add_edge_(0,1) G.add_edge_(1,2) # this should succeed fd,fname = tempfile.mkstemp() os.close(fd) memlist.write(G,fname) # this should fail because the graph isn't compact G.rm_edge_(e1) try: memlist.write(G,fname) self.fail('Writing an uncompact graph should raise an exception') except zen.ZenException: pass
def test_write_compact_undirected(self): G = zen.Graph() G.add_nodes(5) e1 = G.add_edge_(0, 1) G.add_edge_(1, 2) # this should succeed fd, fname = tempfile.mkstemp() os.close(fd) memlist.write(G, fname) # this should fail because the graph isn't compact G.rm_edge_(e1) try: memlist.write(G, fname) self.fail('Writing an uncompact graph should raise an exception') except zen.ZenException: pass