示例#1
0
class TestGraphBase(unittest.TestCase):
    def setUp(self):
        self.G=Graph([[None]])
        self.costs={}    # pair: cost dict.
        self.heads={0:()}
        self.tails={0:()}
        self.sources=(0,)
        self.sinks=(0,)
        self.order=1

    def testCosts(self):
        # print(self.costs)
        for pair, c in self.costs.items():
            # print(pair, c)
            self.assertEqual(self.G.cost(pair[0], pair[1]), c)

    def testHeads(self):
        for V, heads in self.heads.items():
            self.assertEqual(tuple(self.G.heads(V)), heads)

    def testTails(self):
        for V, tails in self.tails.items():
            self.assertEqual(tuple(self.G.tails(V)), tails)

    def testSources(self):
        self.assertEqual(tuple(self.G.sources()), self.sources)

    def testSinks(self):
        self.assertEqual(tuple(self.G.sinks()), self.sinks)

    def testOrder(self):
        self.assertEqual(self.G.order(), self.order)