code: def construct_random_adjacency_matrix(
      num_vertices, avg_edge_frac=0.4, directed=False
  ):
      """Constructs a random adjacency matrix where avg_edge_frac of the edges are connected
      on average."""
      M = np.random.random((num_vertices, num_vertices))
      threshold = avg_edge_frac if directed else 2 * avg_edge_frac
      M = M if directed else (M + M.T)
      A = (M < threshold).astype(np.float)
      np.fill_diagonal(A, 0)
      return A
  
file_path: dragonfly/dragonfly/utils/graph_utils.py
imports: from copy import deepcopy
  import numpy
  from scipy.linalg import eigh
  from .general_utils import get_nonzero_indices_in_vector
label_desc: Use image node_id 1 for calling a global function with example usage: construct_random_adjacency_matrix(num_vertices, avg_edge_frac, directed) and returns: A