# Path: gtfspy/routing/abstract_routing_algorithm.py
# class AbstractRoutingAlgorithm:
#     __metaclass__ = ABCMeta
# 
#     def __init__(self):
#         self._run_time = None
#         self._has_run = None
# 
#     @abstractmethod
#     def _run(self):
#         pass
# 
#     @timeit
#     def run(self):
#         if self._has_run:
#             raise RuntimeError("Algorithm has already run, please initialize a new algorithm")
#         start_time = time.time()
#         self._run()
#         end_time = time.time()
#         self._run_time = end_time - start_time
#         self._has_run = True
# 
#     def get_run_time(self):
#         """
#         Returns
#         -------
#         run_time: float
#             running time of the algorithm in seconds
#         """
#         assert self._has_run
#         return self._run_time


from collections import defaultdict
from gtfspy.routing.abstract_routing_algorithm import AbstractRoutingAlgorithm
import networkx



class ConnectionScan(AbstractRoutingAlgorithm):
    """
    A simple implementation of the Connection Scan Algorithm (CSA) solving the first arrival problem
    for public transport networks.

    http://i11www.iti.uni-karlsruhe.de/extra/publications/dpsw-isftr-13.pdf
    """

    def __init__(self, transit_events, seed_stop, start_time,
                 end_time, transfer_margin, walk_network, walk_speed):
        """
        Parameters
        ----------
        transit_events: list[Connection]
        seed_stop: int
            index of the seed node
        start_time : int
            start time in unixtime seconds
        end_time: 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
        """

# Path: gtfspy/routing/abstract_routing_algorithm.py
# class AbstractRoutingAlgorithm:
#     __metaclass__ = ABCMeta
# 
#     def __init__(self):
#         self._run_time = None
#         self._has_run = None
# 
#     @abstractmethod
#     def _run(self):
#         pass
# 
#     @timeit
#     def run(self):
#         if self._has_run:
#             raise RuntimeError("Algorithm has already run, please initialize a new algorithm")
#         start_time = time.time()
#         self._run()
#         end_time = time.time()
#         self._run_time = end_time - start_time
#         self._has_run = True
# 
#     def get_run_time(self):
#         """
#         Returns
#         -------
#         run_time: float
#             running time of the algorithm in seconds
#         """
#         assert self._has_run
#         return self._run_time


# Path: gtfspy/routing/connection_scan.py
from collections import defaultdict
from gtfspy.routing.abstract_routing_algorithm import AbstractRoutingAlgorithm
import networkx




class ConnectionScan(AbstractRoutingAlgorithm):
    """
    A simple implementation of the Connection Scan Algorithm (CSA) solving the first arrival problem
    for public transport networks.

    http://i11www.iti.uni-karlsruhe.de/extra/publications/dpsw-isftr-13.pdf
    """

    def __init__(self, transit_events, seed_stop, start_time,
                 end_time, transfer_margin, walk_network, walk_speed):
        """
        Parameters
        ----------
        transit_events: list[Connection]
        seed_stop: int
            index of the seed node
        start_time : int
            start time in unixtime seconds
        end_time: 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
        """

        AbstractRoutingAlgorithm.__init__(self)