docs: def connectivity_matrix(cm):
      """Validate the given connectivity matrix."""
      # Special case for empty matrices.
      if cm.size == 0:
          return True
      if cm.ndim != 2:
          raise ValueError("Connectivity matrix must be 2-dimensional.")
      if cm.shape[0] != cm.shape[1]:
          raise ValueError("Connectivity matrix must be square.")
      if not np.all(np.logical_or(cm == 1, cm == 0)):
          raise ValueError("Connectivity matrix must contain only binary "
                           "values.")
      return True