import torch


def mcp_ind_to_adj(ind,n)->torch.Tensor:
    """
    ind should be a set of indices (or iterable)
    Transforms it into the adjacency matrix of shape (n,n)
    """
    assert max(ind)<n, f"Index {max(ind)} not in range for {n} indices"
    adj = torch.zeros((n,n))
    n_indices = len(ind)
    x = [elt for elt in ind for _ in range(n_indices)]
    y = [elt for _ in range(n_indices) for elt in ind]
    adj[x,y] = 1
    adj *= (1-torch.eye(n))
    return adj