code: def find_complement(am, sites=None, bonds=None, asmask=False):
      r
      if (sites is not None) and (bonds is None):
          inds = sp.unique(sites)
          N = am.shape[0]
      elif (bonds is not None) and (sites is None):
          inds = sp.unique(bonds)
          N = int(am.nnz/2)
      elif (bonds is not None) and (sites is not None):
          raise Exception('Only one of sites or bonds can be specified')
      else:
          raise Exception('Either sites or bonds must be specified')
      mask = sp.ones(shape=N, dtype=bool)
      mask[inds] = False
      if asmask:
          return mask
      else:
          return sp.arange(N)[mask]
docs: r"""
      Finds the complementary sites (or bonds) to a given set of inputs
  
      Parameters
      ----------
      am : scipy.sparse matrix
          The adjacency matrix of the network.
  
      sites : array_like (optional)
          The set of sites for which the complement is sought
  
      bonds : array_like (optional)
          The set of bonds for which the complement is sought
  
      asmask : boolean
          If set to ``True`` the result is returned as a boolean mask of the
          correct length with ``True`` values indicate the complements.  The
          default is ``False`` which returns a list of indices instead.
  
      Returns
      -------
      An array containing indices of the sites (or bonds) that are not part of
      the input list.
  
      Notes
      -----
      Either ``sites`` or ``bonds`` must be specified