code: def clean_community_indexes(communityID):
      
      communityID = np.array(communityID)
      cid_shape = communityID.shape
      if len(cid_shape) > 1:
          communityID = communityID.flatten()
      new_communityID = np.zeros(len(communityID))
      for i, n in enumerate(np.unique(communityID)):
          new_communityID[communityID == n] = i
      if len(cid_shape) > 1:
          new_communityID = new_communityID.reshape(cid_shape)
      return new_communityID
docs: Takes input of community assignments. Returns reindexed community assignment by using smallest numbers possible.
  
      Parameters
      ----------
  
      communityID : array-like
          list or array of integers. Output from community detection algorithems.
  
      Returns
      -------
  
      new_communityID : array
          cleaned list going from 0 to len(np.unique(communityID))-1
  
      Note
      -----
  
      Behaviour of funciton entails that the lowest community integer in communityID will recieve the lowest integer in new_communityID.