예제 #1
0
def example_railsystem():
    railsystem = RailSystem()
    # Graph: AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7
    railsystem.add_rail('A', 'B', 5)
    railsystem.add_rail('B', 'C', 4)
    railsystem.add_rail('C', 'D', 8)
    railsystem.add_rail('D', 'C', 8)
    railsystem.add_rail('D', 'E', 6)
    railsystem.add_rail('A', 'D', 5)
    railsystem.add_rail('C', 'E', 2)
    railsystem.add_rail('E', 'B', 3)
    railsystem.add_rail('A', 'E', 7)
    return railsystem
예제 #2
0
    def setUp(self):
        self.railsystem = RailSystem()
        # Graph: AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7
        self.railsystem.add_rail('A', 'B', 5)
        self.railsystem.add_rail('B', 'C', 4)
        self.railsystem.add_rail('C', 'D', 8)
        self.railsystem.add_rail('D', 'C', 8)
        self.railsystem.add_rail('D', 'E', 6)
        self.railsystem.add_rail('A', 'D', 5)
        self.railsystem.add_rail('C', 'E', 2)
        self.railsystem.add_rail('E', 'B', 3)
        self.railsystem.add_rail('A', 'E', 7)

        self.trips = [(['A', 'B', 'C'], 9), (['A', 'D'], 5),
                      (['A', 'D', 'C'], 13), (['A', 'E', 'B', 'C', 'D'], 22),
                      (['A', 'E', 'D'], NoSuchRoute)]