def get_min_ncut(ev, d, w, num_cuts):
 mcut = np.inf
 mn = ev.min()
 mx = ev.max()
 min_mask = np.zeros_like(ev, dtype=np.bool)
 if np.allclose(mn, mx):
  return (min_mask, mcut)
 for t in np.linspace(mn, mx, num_cuts, endpoint=False):
  mask = (ev > t)
  cost = _ncut.ncut_cost(mask, d, w)
  if (cost < mcut):
   min_mask = mask
   mcut = cost
 return (min_mask, mcut)

def get_min_ncut ( ev , d , w , num_cuts ) : mcut = np . inf mn = ev . min ( ) mx = ev . max ( ) min_mask = np . zeros_like ( ev , dtype = np . bool ) if np . allclose ( mn , mx ) : return ( min_mask , mcut ) for t in np . linspace ( mn , mx , num_cuts , endpoint = False ) : mask = ( ev > t ) cost = _ncut . ncut_cost ( mask , d , w ) if ( cost < mcut ) : min_mask = mask mcut = cost return ( min_mask , mcut )
threshold an eigenvector evenly .