def minimise(routing_table, target_length):
    """Reduce the size of a routing table by merging together entries where
    possible and by removing any remaining default routes.

    .. warning::

        The input routing table *must* also include entries which could be
        removed and replaced by default routing.

    .. warning::

        It is assumed that the input routing table is not in any particular
        order and may be reordered into ascending order of generality (number
        of don't cares/Xs in the key-mask) without affecting routing
        correctness.  It is also assumed that if this table is unordered it is
        at least orthogonal (i.e., there are no two entries which would match
        the same key) and reorderable.

        .. note::

            If *all* the keys in the table are derived from a single instance
            of :py:class:`~rig.bitfield.BitField` then the table is guaranteed
            to be orthogonal and reorderable.

        .. note::

            Use :py:meth:`~rig.routing_table.expand_entries` to generate an
            orthogonal table and receive warnings if the input table is not
            orthogonal.

    Parameters
    ----------
    routing_table : [:py:class:`~rig.routing_table.RoutingTableEntry`, ...]
        Routing entries to be merged.
    target_length : int or None
        Target length of the routing table; the minimisation procedure will
        halt once either this target is reached or no further minimisation is
        possible. If None then the table will be made as small as possible.

    Raises
    ------
    MinimisationFailedError
        If the smallest table that can be produced is larger than
        `target_length`.

    Returns
    -------
    [:py:class:`~rig.routing_table.RoutingTableEntry`, ...]
        Reduced routing table entries.
    """
    table, _ = ordered_covering(routing_table, target_length, no_raise=True)
    return remove_default_routes(table, target_length)
Reduce the size of a routing table by merging together entries where
    possible and by removing any remaining default routes.

    .. warning::

        The input routing table *must* also include entries which could be
        removed and replaced by default routing.

    .. warning::

        It is assumed that the input routing table is not in any particular
        order and may be reordered into ascending order of generality (number
        of don't cares/Xs in the key-mask) without affecting routing
        correctness.  It is also assumed that if this table is unordered it is
        at least orthogonal (i.e., there are no two entries which would match
        the same key) and reorderable.

        .. note::

            If *all* the keys in the table are derived from a single instance
            of :py:class:`~rig.bitfield.BitField` then the table is guaranteed
            to be orthogonal and reorderable.

        .. note::

            Use :py:meth:`~rig.routing_table.expand_entries` to generate an
            orthogonal table and receive warnings if the input table is not
            orthogonal.

    Parameters
    ----------
    routing_table : [:py:class:`~rig.routing_table.RoutingTableEntry`, ...]
        Routing entries to be merged.
    target_length : int or None
        Target length of the routing table; the minimisation procedure will
        halt once either this target is reached or no further minimisation is
        possible. If None then the table will be made as small as possible.

    Raises
    ------
    MinimisationFailedError
        If the smallest table that can be produced is larger than
        `target_length`.

    Returns
    -------
    [:py:class:`~rig.routing_table.RoutingTableEntry`, ...]
        Reduced routing table entries.