# Path: gtfspy/routing/connection.py
# class Connection:
# 
#     WALK_SEQ = -1
#     WALK_TRIP_ID = -1
# 
#     def __init__(self, departure_stop, arrival_stop, departure_time, arrival_time, trip_id, seq,
#                  is_walk=False, arrival_stop_next_departure_time=float('inf')):
#         self.departure_stop = departure_stop
#         self.arrival_stop = arrival_stop
#         self.departure_time = departure_time
#         self.arrival_time = arrival_time
#         self.trip_id = trip_id
#         self.is_walk = is_walk
#         self.seq = int(seq)
#         self.arrival_stop_next_departure_time = arrival_stop_next_departure_time
# 
#     def duration(self):
#         return self.arrival_time - self.departure_time
# 
#     def __str__(self):
#         return pformat(self.__dict__)
# 
#     def __eq__(self, other):
#         return self.__dict__ == other.__dict__
# 
#     def __repr__(self):
#         return '<%s:%s:%s:%s:%s:%s:%s:%s>' % (
#             self.__class__.__name__, self.departure_stop, self.arrival_stop,
#             self.departure_time, self.arrival_time, self.trip_id, self.is_walk, self.arrival_stop_next_departure_time)
# 
#     def __hash__(self):
#         return hash(self.__repr__())


from gtfspy.routing.connection import Connection
    transit_connections: list[Connection]
    start_time_dep : int
        start time in unixtime seconds
    end_time_dep: int
        end time in unixtime seconds (no new connections will be scanned after this time)
    transfer_margin: int
        required extra margin required for transfers in seconds
    walk_speed: float
        walking speed between stops in meters / second
    walk_network: networkx.Graph
        each edge should have the walking distance as a data attribute ("d_walk") expressed in meters

    Returns
    -------
    pseudo_connections: set[Connection]
    """
    # A pseudo-connection should be created after (each) arrival to a transit_connection's arrival stop.
    pseudo_connection_set = set()  # use a set to ignore possible duplicates
    for c in transit_connections:
        if start_time_dep <= c.departure_time <= end_time_dep:
            walk_arr_stop = c.departure_stop
            walk_arr_time = c.departure_time - transfer_margin
            for _, walk_dep_stop, data in walk_network.edges(nbunch=[walk_arr_stop], data=True):
                walk_dep_time = walk_arr_time - data['d_walk'] / float(walk_speed)
                if walk_dep_time > end_time_dep or walk_dep_time < start_time_dep:
                    continue
                pseudo_connection = Connection(walk_dep_stop,
                                               walk_arr_stop,
                                               walk_dep_time,
                                               walk_arr_time,

# Path: gtfspy/routing/connection.py
# class Connection:
# 
#     WALK_SEQ = -1
#     WALK_TRIP_ID = -1
# 
#     def __init__(self, departure_stop, arrival_stop, departure_time, arrival_time, trip_id, seq,
#                  is_walk=False, arrival_stop_next_departure_time=float('inf')):
#         self.departure_stop = departure_stop
#         self.arrival_stop = arrival_stop
#         self.departure_time = departure_time
#         self.arrival_time = arrival_time
#         self.trip_id = trip_id
#         self.is_walk = is_walk
#         self.seq = int(seq)
#         self.arrival_stop_next_departure_time = arrival_stop_next_departure_time
# 
#     def duration(self):
#         return self.arrival_time - self.departure_time
# 
#     def __str__(self):
#         return pformat(self.__dict__)
# 
#     def __eq__(self, other):
#         return self.__dict__ == other.__dict__
# 
#     def __repr__(self):
#         return '<%s:%s:%s:%s:%s:%s:%s:%s>' % (
#             self.__class__.__name__, self.departure_stop, self.arrival_stop,
#             self.departure_time, self.arrival_time, self.trip_id, self.is_walk, self.arrival_stop_next_departure_time)
# 
#     def __hash__(self):
#         return hash(self.__repr__())


# Path: gtfspy/routing/pseudo_connections.py
from gtfspy.routing.connection import Connection

    transit_connections: list[Connection]
    start_time_dep : int
        start time in unixtime seconds
    end_time_dep: int
        end time in unixtime seconds (no new connections will be scanned after this time)
    transfer_margin: int
        required extra margin required for transfers in seconds
    walk_speed: float
        walking speed between stops in meters / second
    walk_network: networkx.Graph
        each edge should have the walking distance as a data attribute ("d_walk") expressed in meters

    Returns
    -------
    pseudo_connections: set[Connection]
    """
    # A pseudo-connection should be created after (each) arrival to a transit_connection's arrival stop.
    pseudo_connection_set = set()  # use a set to ignore possible duplicates
    for c in transit_connections:
        if start_time_dep <= c.departure_time <= end_time_dep:
            walk_arr_stop = c.departure_stop
            walk_arr_time = c.departure_time - transfer_margin
            for _, walk_dep_stop, data in walk_network.edges(nbunch=[walk_arr_stop], data=True):
                walk_dep_time = walk_arr_time - data['d_walk'] / float(walk_speed)
                if walk_dep_time > end_time_dep or walk_dep_time < start_time_dep:
                    continue
                pseudo_connection = Connection(walk_dep_stop,
                                               walk_arr_stop,
                                               walk_dep_time,
                                               walk_arr_time,

                                               Connection.WALK_TRIP_ID,