def test_xml_hypergraph(self): gr = testlib.new_hypergraph() dotstr = markup.write(gr) gr1 = markup.read(dotstr) dotstr = markup.write(gr1) gr2 = markup.read(dotstr) graph_equality(gr1, gr2)
def test_dot_for_hypergraph(self): gr = testlib.new_hypergraph() dotstr = dot.write(gr) gr1 = dot.read_hypergraph(dotstr) dotstr = dot.write(gr1) gr2 = dot.read_hypergraph(dotstr) graph_equality(gr1, gr2)
def test_order_len_equivlance(self): """ Verify the behavior of G.order() """ gr = testlib.new_hypergraph() assert len(gr) == gr.order() assert gr.order() == len(gr.node_links)
def test_remove_node(self): gr = testlib.new_hypergraph() gr.del_node(0) self.assertTrue(0 not in gr.nodes()) for e in gr.hyperedges(): for n in gr.links(e): self.assertTrue(n in gr.nodes())
def test_dot_xml_hypergraph(self): gr = testlib.new_hypergraph() dotstr = markup.write(gr) gr1 = markup.read(dotstr) dotstr = markup.write(gr1) gr2 = markup.read(dotstr) graph_equality(gr1, gr2)
def test_repr(self): """ Validate the repr string """ gr = testlib.new_hypergraph() gr_repr = repr(gr) assert isinstance(gr_repr, str) assert gr.__class__.__name__ in gr_repr
def test_rank(self): # Uniform case gr = testlib.new_uniform_hypergraph(3) assert 3 == gr.rank() # Non-uniform case gr = testlib.new_hypergraph() num = max([len(gr.links(e)) for e in gr.hyperedges()]) assert num == gr.rank()
def test_output_names_in_dot(self): gr1 = testlib.new_graph() gr1.name = "Some name 1" gr2 = testlib.new_digraph() gr2.name = "Some name 2" gr3 = testlib.new_hypergraph() gr3.name = "Some name 3" assert "Some name 1" in dot.write(gr1) assert "Some name 2" in dot.write(gr2) assert "Some name 3" in dot.write(gr3)
def test_remove_edge(self): h = hypergraph() h.add_nodes([1, 2]) h.add_edges(['a', 'b']) h.link(1, 'a') h.link(2, 'a') h.link(1, 'b') h.link(2, 'b') # Delete an edge h.del_edge('a') assert 1 == len(h.hyperedges()) gr = testlib.new_hypergraph() edge_no = len(gr.nodes()) + 1 gr.del_hyperedge(edge_no) self.assertTrue(edge_no not in gr.hyperedges())
def test_remove_edge(self): h = hypergraph() h.add_nodes([1,2]) h.add_edges(['a', 'b']) h.link(1,'a') h.link(2,'a') h.link(1,'b') h.link(2,'b') # Delete an edge h.del_edge('a') assert 1 == len(h.hyperedges()) gr = testlib.new_hypergraph() edge_no = len(gr.nodes())+1 gr.del_hyperedge(edge_no) self.assertTrue(edge_no not in gr.hyperedges())