예제 #1
0
 def _test_rate(self, i, j):
     reducer = GraphReduction(self.rates, [i], [j], debug=True)
     reducer.check_graph()
     reducer.compute_rates()
     rAB = reducer.get_rate_AB()
     rBA = reducer.get_rate_BA()
     reducer.check_graph()
     self.assertEqual(reducer.graph.number_of_nodes(), 2)
     self.assertEqual(reducer.graph.number_of_edges(), 4)
     self.assertAlmostEqual(rAB, self.final_rate, 7)
     self.assertAlmostEqual(rBA, self.final_rate, 7)
예제 #2
0
 def do_check(self, A, B, nnodes=20, nedges=20):
     maker = _MakeRandomGraph(nnodes=20, nedges=20, node_set=A+B)
     graph = maker.run()
     reducer = GraphReduction(maker.rates, A, B, debug=False)  
     reducer.check_graph()
     reducer.compute_rates()
     rAB = reducer.get_rate_AB()
     rBA = reducer.get_rate_BA()
     reducer.check_graph()
     self.assertEqual(reducer.graph.number_of_nodes(), len(A) + len(B))
     if len(A) == 1 and len(B) == 1:
         self.assertLessEqual(reducer.graph.number_of_edges(), 4)