def test_radius(self): self.obj = ParsedGraph(NetJsonParser(data=biconnected_graph)) self.obj.condensate_graph() for node, data in self.obj.condensed_graph.nodes(data=True): self.assertTrue("radius" in data) self.assertTrue(data["radius"] <= self.obj.max_node_size) self.assertTrue(data["radius"] >= 1)
def test_disconnected_graph_size(self): self.obj = ParsedGraph(NetJsonParser(data=disconnected_graph)) self.obj.condensate_graph() n = 0 for node, data in self.obj.condensed_graph.nodes(data=True): if data["type"] == "cutpoint": n += 1 if data["type"] == "block": n += int(data["nodes in block"]) self.assertEqual(n, len(self.obj.graph))
def test_disconnected_graph(self): self.obj = ParsedGraph(NetJsonParser(data=disconnected_graph)) self.obj.condensate_graph() self.assertFalse(nx.is_connected(self.obj.condensed_graph))
def test_type(self): self.obj = ParsedGraph(NetJsonParser(data=biconnected_graph)) self.obj.condensate_graph() for node, data in self.obj.condensed_graph.nodes(data=True): self.assertTrue(data["type"] in ("cutpoint", "block"))
def test_connected(self): self.obj = ParsedGraph(NetJsonParser(data=biconnected_graph)) self.obj.condensate_graph() self.assertTrue(nx.is_connected(self.obj.graph) == nx.is_connected(self.obj.condensed_graph))
def test_empty(self): self.obj = ParsedGraph(NetJsonParser(data=empty_graph)) self.obj.condensate_graph() self.assertEqual(len(self.obj.condensed_graph), 0)
def setUp(self): self.obj = ParsedGraph(NetJsonParser(data=biconnected_graph))
class TestCondensateGraph(unittest.TestCase): def setUp(self): self.obj = ParsedGraph(NetJsonParser(data=biconnected_graph)) def test_netjson(self): self.assertTrue(self.obj.netJSON) def test_graph(self): self.assertTrue(self.obj.graph) def test_empty(self): self.obj = ParsedGraph(NetJsonParser(data=empty_graph)) self.obj.condensate_graph() self.assertEqual(len(self.obj.condensed_graph), 0) def test_size(self): self.obj = ParsedGraph(NetJsonParser(data=biconnected_graph)) self.obj.condensate_graph() n = 0 for node, data in self.obj.condensed_graph.nodes(data=True): if data["type"] == "cutpoint": n += 1 if data["type"] == "block": n += int(data["nodes in block"]) self.assertEqual(n, len(self.obj.graph)) def test_connected(self): self.obj = ParsedGraph(NetJsonParser(data=biconnected_graph)) self.obj.condensate_graph() self.assertTrue(nx.is_connected(self.obj.graph) == nx.is_connected(self.obj.condensed_graph)) def test_type(self): self.obj = ParsedGraph(NetJsonParser(data=biconnected_graph)) self.obj.condensate_graph() for node, data in self.obj.condensed_graph.nodes(data=True): self.assertTrue(data["type"] in ("cutpoint", "block")) def test_radius(self): self.obj = ParsedGraph(NetJsonParser(data=biconnected_graph)) self.obj.condensate_graph() for node, data in self.obj.condensed_graph.nodes(data=True): self.assertTrue("radius" in data) self.assertTrue(data["radius"] <= self.obj.max_node_size) self.assertTrue(data["radius"] >= 1) def test_disconnected_graph(self): self.obj = ParsedGraph(NetJsonParser(data=disconnected_graph)) self.obj.condensate_graph() self.assertFalse(nx.is_connected(self.obj.condensed_graph)) def test_disconnected_graph_size(self): self.obj = ParsedGraph(NetJsonParser(data=disconnected_graph)) self.obj.condensate_graph() n = 0 for node, data in self.obj.condensed_graph.nodes(data=True): if data["type"] == "cutpoint": n += 1 if data["type"] == "block": n += int(data["nodes in block"]) self.assertEqual(n, len(self.obj.graph))