def eliminate_self_loops(A):
    """Remove self-loops from the adjacency matrix."""
    A = A.tolil()
    A.setdiag(0)
    A = A.tocsr()
    A.eliminate_zeros()
    return A
Remove self-loops from the adjacency matrix.
python/dgl/data/gnn_benchmark.py