code: def density_und(CIJ):
      '''
      Density is the fraction of present connections to possible connections.
  
      Parameters
      ----------
      CIJ : NxN np.ndarray
          undirected (weighted/binary) connection matrix
  
      Returns
      -------
      kden : float
          density
      N : int
          number of vertices
      k : int
          number of edges
  
      Notes
      -----
      Assumes CIJ is undirected and has no self-connections.
              Weight information is discarded.
      '''
      n = len(CIJ)
      k = np.size(np.where(np.triu(CIJ).flatten()))
      kden = k / ((n * n - n) / 2)
      return kden, n, f density_und(CIJ):
      '''
      Density is the fraction of present connections to possible connections.
  
      Parameters
      ----------
      CIJ : NxN np.ndarray
          undirected (weighted/binary) connection matrix
  
      Returns
      -------
      kden : float
          density
      N : int
          number of vertices
      k : int
          number of edges
  
      Notes
      -----
      Assumes CIJ is undirected and has no self-connections.
              Weight information is discarded.
      '''
      n = len(CIJ)
      k = np.size(np.where(np.triu(CIJ).flatten()))
      kden = k / ((n * n - n) / 2)
      return kden, n, k
docs: Density is the fraction of present connections to possible connections.
  
      Parameters
      ----------
      CIJ : NxN np.ndarray
          undirected (weighted/binary) connection matrix
  
      Returns
      -------
      kden : float
          density
      N : int
          number of vertices
      k : int
          number of edges
  
      Notes
      -----
      Assumes CIJ is undirected and has no self-connections.
              Weight information is discarded.