code: def getMinimumConnection(
      mat: torch.Tensor,
      max_N: torch.Tensor,
      n_list: torch.Tensor,
      device: torch.device,
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      """
      Generate connections until fully connect all the nodes in the graph.
      If the graph is not fully connected, it might generate inaccurate results.
      """
      p_value = torch.tensor(1)
      affinity_mat = getAffinityGraphMat(mat, p_value)
      for i, p_value in enumerate(n_list):
          fully_connected = isGraphFullyConnected(affinity_mat, device)
          affinity_mat = getAffinityGraphMat(mat, p_value)
          if fully_connected or p_value > max_N:
              break
  
      return affinity_mat, p_value
  
imports: from typing import Dict, List, Tuple
  import torch
  from torch.linalg import eigh, eigvalsh
label_desc: Use image node_id 10 for calling a global function with example usage: getMinimumConnection(mat, max_N, n_list, device) and returns: affinity_mat,  p_value