source = 'A' dest = 'B' # Define a network model and load interfaces model1 = PerformanceModel() model1.add_network_interfaces_from_list(network_interfaces) print('model1 is type', type(model1)) print() # Assign lat/lon info to nodes print('Assigning lat/lon info to nodes') lat_lon_info = [(180, 20), (30, 40), (120, 50), (35, 67), (77, 88), (45, 56)] node_names = [node.name for node in model1.node_objects] counter = 0 for name in node_names: node = model1.get_node_object(name) lat, lon = lat_lon_info[counter] node.lat = lat node.lon = lon counter = counter + 1 print() # create demand objects from list of demands # demand_objects = Demand.create_demand_objects(demands) for demand in demands: model1.add_demand(demand['source'], demand['dest'], demand['traffic']) # find the best path from node A to B best_A_B = model1.get_shortest_path(source, dest) print("The best path from Node A to Node B is:", best_A_B)
source = "A" dest = "B" # Define a network model and load interfaces model1 = PerformanceModel() model1.add_network_interfaces_from_list(network_interfaces) print("model1 is type", type(model1)) print() # Assign lat/lon info to nodes print("Assigning lat/lon info to nodes") lat_lon_info = [(180, 20), (30, 40), (120, 50), (35, 67), (77, 88), (45, 56)] node_names = [node.name for node in model1.node_objects] counter = 0 for name in node_names: node = model1.get_node_object(name) lat, lon = lat_lon_info[counter] node.lat = lat node.lon = lon counter = counter + 1 print() # create demand objects from list of demands # demand_objects = Demand.create_demand_objects(demands) for demand in demands: model1.add_demand(demand["source"], demand["dest"], demand["traffic"]) # find the best path from node A to B best_A_B = model1.get_shortest_path(source, dest) print("The best path from Node A to Node B is:", best_A_B) print()