def test_graph_level0(self): G = self.G G.add_edge(2, 1) G.add_edge(3, 1) G.add_edge(4, 1) self.assertEqual(graphs.get_graph_value(G, 1), 4.0) self.assertEqual(graphs.get_graph_value(G, 2), 1) self.assertEqual(graphs.get_graph_value(G, 3), 1) self.assertEqual(graphs.get_graph_value(G, 4), 1)
def test_graph_level2(self): G = self.G G.add_edge(3, 1) G.add_edge(4, 1) G.add_edge(4, 2) self.assertEqual(graphs.get_graph_value(G, 1), 2.5) self.assertEqual(graphs.get_graph_value(G, 2), 1.5) self.assertEqual(graphs.get_graph_value(G, 3), 1) self.assertEqual(graphs.get_graph_value(G, 4), 1)
def get_graph_value(self): graph = self.get_graph() return get_graph_value(graph, self.id)