Example #1
0
def get_active_stations():
  updated_metro = vc_metro
  for station_under_construction in stations_under_construction:
    for current_station, neighboring_stations in vc_metro.items():
      if current_station != station_under_construction:
        updated_metro[current_station] -= set(stations_under_construction)
      else:
        updated_metro[current_station] = set([])
  return updated_metro
Example #2
0
def get_active_stations():                    # returns graph of available stations
  updated_metro = vc_metro
  for station_under_construction in stations_under_construction:
    for current_station, neighbouring_stations in vc_metro.items():
      if current_station != station_under_construction: # remove any references to closed stations
        updated_metro[current_station] -= set(stations_under_construction)
      else:                                   # if station closed, remove all connections
        updated_metro[current_station] = set([])
  return updated_metro
Example #3
0
def get_active_stations():
    updated_metro = vc_metro
    for station_under_construction in stations_under_construction:
        for current_station, neighboring_stations in vc_metro.items():
            if current_station != station_under_construction:
                updated_metro[current_station] -= set(
                    stations_under_construction
                )  # Remove the connections between current and constructing stations
            else:
                updated_metro[current_station] = set([])
    return updated_metro
Example #4
0
def get_active_stations():
    updated_metro = vc_metro
    #loop checking for any connections to and from stations which are closed
    for station_under_construction in stations_under_construction:
        for current_station, neighboring_station in vc_metro.items():
            if current_station != station_under_construction:
                #this will set substract stations under construction from updated_metro.
                updated_metro[current_station] -= set(
                    stations_under_construction)
            #when the current_station is a station_under_construction
            else:
                updated_metro[current_station] = set([])

    return updated_metro
Example #5
0
def get_active_stations():
  # we copy the stations dictionary
  updated_metro = vc_metro
  # in order to create the updated system, we need to remove any connections to and from the closed stations

  # we loop through the list of stations_under_construction
  for station_under_construction in stations_under_construction:
    # loop through all keys and values in the vc_metro dictionary
    for current_station, neighboring_stations in vc_metro.items():
      # check if the current station is not the station under construction we are looking at in the outer loop
      if station_under_construction != current_station:
        # if it’s not, we want to remove any of its connecting stations that are under construction
        # we add the current station to the new dictionary with a value of its current set of stations
        # minus a set of the stations_under_construction
        updated_metro[current_station] = neighboring_stations - set(stations_under_construction)
      else:
        # if the current_station is the station_under_construction
        # we add it to the new dictionary with a value of a set with an empty list that means no connections to and from this station
        # this will allow us to keep the current landmarks dictionary but prevent any connections from the stations that are under repair
        updated_metro[current_station] = set([])

  # when the loops are finished the new graph is ready
  return updated_metro