def setUp(self): self.S1 = CompoundNode.getInstance('S1', [1, 2]) self.S2 = CompoundNode.getInstance('S2', [3, 4, 5, 6]) self.mincutTree = MinCutTree() self.mincutTree.add_edge(self.S1, self.S2, capacity=17)
class MinCutTreeTests(unittest.TestCase): def setUp(self): self.S1 = CompoundNode.getInstance('S1', [1, 2]) self.S2 = CompoundNode.getInstance('S2', [3, 4, 5, 6]) self.mincutTree = MinCutTree() self.mincutTree.add_edge(self.S1, self.S2, capacity=17) def test_getNextNonSingletonNode(self): n = self.mincutTree.getNextNonSingletonNode() self.assertEqual('S2', n) self.mincutTree.remove_node(n) n = self.mincutTree.getNextNonSingletonNode() self.assertEqual('S1', n) self.mincutTree.remove_node(n) self.assertEqual(None, self.mincutTree.getNextNonSingletonNode()) def test_splitNode(self): S11 = CompoundNode.getInstance('S11', [1]) S12 = CompoundNode.getInstance('S12', [2]) self.mincutTree.splitNode(self.S1, (S11, S12, 18), [(S12, self.S2, 17)]) self.assertEqual(set([self.S2, S11, S12]), set(self.mincutTree.nodes())) self.assertEqual(set([(self.S2, S12), (S11, S12)]), set(self.mincutTree.edges()))