def relevant_connections(n, _from, to):
    """Construct a connectivity matrix.

    Args:
        n (int): The dimensions of the matrix
        _from (tuple[int]): Nodes with outgoing connections to ``to``
        to (tuple[int]): Nodes with incoming connections from ``_from``

    Returns:
        np.ndarray: An |n x n| connectivity matrix with the |i,jth| entry is
        ``1`` if |i| is in ``_from`` and |j| is in ``to``, and 0 otherwise.
    """
    cm = np.zeros((n, n))

    # Don't try and index with empty arrays. Older versions of NumPy
    # (at least up to 1.9.3) break with empty array indices.
    if not _from or not to:
        return cm

    cm[np.ix_(_from, to)] = 1
    return cm