当前位置: 首页>>代码示例>>Python>>正文


Python Network.get_city_hubs方法代码示例

本文整理汇总了Python中Network.Network.get_city_hubs方法的典型用法代码示例。如果您正苦于以下问题:Python Network.get_city_hubs方法的具体用法?Python Network.get_city_hubs怎么用?Python Network.get_city_hubs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Network.Network的用法示例。


在下文中一共展示了Network.get_city_hubs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from Network import Network [as 别名]
# 或者: from Network.Network import get_city_hubs [as 别名]
class NetworkController:
    def __init__(self):
        self.network = Network()

    def run(self):
        json_file = './data/CSAir.json'
        self.create_network(json_file)
        self.print_menu()
        while True:
            i = raw_input('Enter a menu code: ')

            if i == '0':
                exit(0)
            elif i == '1':
                print self.network.get_metros()
            elif i == '2':
                print 'Enter a city code: '
                code = raw_input()
                print self.network.get_metro_info(code) + '\n'
            elif i == '3':
                print self.network.get_longest_route() + '\n'
            elif i == '4':
                print self.network.get_shortest_route() + '\n'
            elif i == '5':
                print self.network.get_average_route() + '\n'
            elif i == '6':
                print self.network.get_biggest_city() + '\n'
            elif i == '7':
                print self.network.get_smallest_city() + '\n'
            elif i == '8':
                print self.network.get_average_size() + '\n'
            elif i == '9':
                print self.network.get_continents() + '\n'
            elif i == '10':
                print self.network.get_city_hubs() + '\n'
            elif i == '11':
                print self.network.get_url() + '\n'
            elif i.lower() == 'menu':
                self.print_menu()
            else:
                print 'Input not understood.'

    '''
    print menu for TUI
    '''
    @staticmethod
    def print_menu():
        print '\nWELCOME TO CSAIR, PLEASE SELECT A NUMBER' \
              '\n0: EXIT' \
              '\n1: CITIES' \
              '\n2: CITY INFO' \
              '\n3: LONGEST ROUTE' \
              '\n4: SHORTEST ROUTE' \
              '\n5: AVERAGE ROUTE' \
              '\n6: LARGEST POPULATION' \
              '\n7: SMALLEST POPULATION' \
              '\n8: AVERAGE POPULATION' \
              '\n9: CONTINENTS SERVED' \
              '\n10: CITY HUBS' \
              '\n11: NETWORK MAP' \
              '\n\nType menu to see menu'

    '''
    create network from file
    @param json_file: json file to parse for network
    '''
    def create_network(self, json_file):
        with open(json_file,'r') as f:
            data = json.loads(f.read())
            self.network.create_metros(data['metros'])
            self.network.create_routes(data['routes'])
开发者ID:shravanbyra,项目名称:CS242,代码行数:73,代码来源:NetworkController.py

示例2: __init__

# 需要导入模块: from Network import Network [as 别名]
# 或者: from Network.Network import get_city_hubs [as 别名]
class NetworkController:
    def __init__(self):
        self.network = Network()

    def run(self):
        json_file = '../data/CSAir_revised.json'
        self.create_network(json_file)
        self.print_menu()
        while True:
            i = raw_input('Enter a menu code: ')

            if i == '0':
                exit(0)
            elif i == '1':
                print self.network.get_metros()
            elif i == '2':
                code = raw_input('Enter a city code: ')
                print '\n' + self.network.get_metro_info(code) + '\n'
            elif i == '3':
                self.get_network_statistics()
            elif i == '4':
                print '\n' + self.network.get_url() + '\n'
            elif i == '5':
                self.add_info()
            elif i == '6':
                self.remove_info()
            elif i == '7':
                self.edit_metro()
            elif i == '8':
                self.route_info()
            elif i == '9':
                self.network.save_network()
                print 'Network saved.'
            elif i.lower() == 'menu':
                self.print_menu()
            else:
                print 'Input not understood.'

    '''
    print menu for TUI
    '''

    @staticmethod
    def print_menu():
        print '\nWELCOME TO CSAIR, PLEASE SELECT A NUMBER' \
              '\n0: EXIT' \
              '\n1: CITIES' \
              '\n2: CITY INFO' \
              '\n3: CSAir STATISTICS' \
              '\n4: NETWORK MAP' \
              '\n5: ADD INFO' \
              '\n6: REMOVE INFO' \
              '\n7: EDIT METRO' \
              '\n8: GET TRIP INFO' \
              '\n9: SAVE NETWORK' \
              '\n\nType menu to see menu'

    '''
    create network from file
    @param json_file: json file to parse for network
    '''

    def create_network(self, json_file):
        f = open(json_file, 'r')
        data = json.loads(f.read())
        self.network.create_metros(data['metros'])
        self.network.create_routes(data['routes'])
        f.close()

    def get_network_statistics(self):

        print '\n1: LONGEST ROUTE' \
              '\n2: SHORTEST ROUTE' \
              '\n3: AVERAGE ROUTE' \
              '\n4: LARGEST POPULATION' \
              '\n5: SMALLEST POPULATION' \
              '\n6: AVERAGE POPULATION' \
              '\n7: CONTINENTS SERVED' \
              '\n8: CITY HUBS'
        i = raw_input('Enter a code: ')

        if i == '1':
            print '\n' + self.network.get_longest_route() + '\n'
        elif i == '2':
            print '\n' + self.network.get_shortest_route() + '\n'
        elif i == '3':
            print '\n' + self.network.get_average_route() + '\n'
        elif i == '4':
            print '\n' + self.network.get_biggest_city() + '\n'
        elif i == '5':
            print '\n' + self.network.get_smallest_city() + '\n'
        elif i == '6':
            print '\n' + self.network.get_average_size() + '\n'
        elif i == '7':
            print '\n' + self.network.get_continents() + '\n'
        elif i == '8':
            print '\n' + self.network.get_city_hubs() + '\n'

    def add_info(self):
        print '\n1: ADD METRO' \
#.........这里部分代码省略.........
开发者ID:shravanbyra,项目名称:CS242,代码行数:103,代码来源:NetworkController.py


注:本文中的Network.Network.get_city_hubs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。