def test_fmax_constrains(self):

        graph_obj = Graph.build_from_parameters(2, 10, 1, 2)

        network_obj = TransportNetwork(graph_obj)
        [bus_obj, metro_obj] = TransportMode.get_default_modes()
        radial_bus = network_obj.get_radial_routes(bus_obj)
        feeder_bus = network_obj.get_feeder_routes(bus_obj)
        radial_metro = network_obj.get_radial_routes(metro_obj, short=True)

        for route in radial_bus:
            network_obj.add_route(route)

        for route in feeder_bus:
            network_obj.add_route(route)

        for route in radial_metro:
            network_obj.add_route(route)

        f = defaultdict(float)
        for route in network_obj.get_routes():
            f[route.id] = 28

        ineq_f = Constrains.fmax_constrains(graph_obj,
                                            network_obj.get_routes(),
                                            network_obj.get_modes(), f)

        self.assertEqual(ineq_f, [
            -136.0, -40.0, -136.0, -40.0, -143.0, -12.0, -143.0, -12.0, -150.0,
            -40.0, -150.0, -40.0, -136.0, -40.0, -136.0, -40.0, -143.0, -12.0,
            -143.0, -12.0
        ])
    def get_mode_network_distance(graph_obj: Graph,
                                  network_obj: TransportNetwork,
                                  f: defaultdict_float) -> defaultdict_float:
        """
        to get total distance builded in each transport mode
        :param network_obj: TransportNetwork object
        :param graph_obj: Graph object
        :param f: dict with frequency for each route_id
        :return: ddict with total distance for each mode in transport network
        """
        edges = graph_obj.get_edges()
        edges_distance = graph_obj.get_edges_distance()

        routes = network_obj.get_routes()
        list_modes = network_obj.get_modes()

        mode_distance = defaultdict(float)

        for mode in list_modes:
            edge_list = []
            for edge in edges:
                d_e = edges_distance[edge.node1.id][edge.node2.id]
                for route in routes:
                    if route.mode == mode:
                        if f[route.id] != 0:
                            node_sequence_i = route.nodes_sequence_i
                            node_sequence_r = route.nodes_sequence_r

                            ver_sum = False
                            for i in range(len(node_sequence_i) - 1):
                                j = i + 1
                                if node_sequence_i[
                                        i] == edge.node1.id and node_sequence_i[
                                            j] == edge.node2.id and (
                                                edge.node1.id, edge.node2.id
                                            ) not in edge_list:
                                    mode_distance[mode] += d_e * mode.d
                                    edge_list.append(
                                        (edge.node1.id, edge.node2.id))
                                    edge_list.append(
                                        (edge.node2.id, edge.node1.id))
                                    ver_sum = True
                                    break
                            if ver_sum is True:
                                break
                            for i in range(len(node_sequence_r) - 1):
                                j = i + 1
                                if node_sequence_r[
                                        i] == edge.node1.id and node_sequence_r[
                                            j] == edge.node2.id and (
                                                edge.node1.id, edge.node2.id
                                            ) not in edge_list:
                                    mode_distance[mode] += d_e * mode.d
                                    edge_list.append(
                                        (edge.node1.id, edge.node2.id))
                                    edge_list.append(
                                        (edge.node2.id, edge.node1.id))
                                    ver_sum = True
                                    break
                            if ver_sum is True:
                                break

        return mode_distance