def remove_topk_nodes(adj, node_importance_rank, topk):

    """
    Remove top k important nodes by removing all the links connecting to the nodes.

    Args:
        adj: The adjacency matrix for the graph.
        node_importance_rank: The sorted indices of nodes following the node importance (descending) order.
        topk: The max number of nodes to remove.

    Returns:
        The modified adjacency matrix.
    """
    for idx in node_importance_rank[:topk]:
        for i in range(adj.shape[0]):
            adj[i, idx] = 0
            adj[idx, i] = 0

    return adj