private boolean passesErdosGallaiTest(){
  MutableDegreeDistribution copy=new MutableSimpleDegreeDistribution(getDegrees());
  int L=copy.size();
  int degreeSum=0;
  for (  int degree : copy.getDegrees()) {
    if (degree < 0) {
      return false;
    }
    degreeSum+=degree;
  }
  if (degreeSum % 2 != 0) {
    return false;
  }
  copy.sort(Collections.reverseOrder());
  for (int k=1; k < L; ++k) {
    int sum=0;
    for (int i=0; i < k; ++i) {
      sum+=copy.get(i);
    }
    int comp=0;
    for (int j=k; j < L; ++j) {
      comp+=min(k,copy.get(j));
    }
    if (sum > k * (k - 1) + comp) {
      return false;
    }
  }
  return true;
}

private boolean passesErdosGallaiTest ( ) { MutableDegreeDistribution copy = new MutableSimpleDegreeDistribution ( getDegrees ( ) ) ; int L = copy . size ( ) ; int degreeSum = 0 ; for ( int degree : copy . getDegrees ( ) ) { if ( degree < 0 ) { return false ; } degreeSum += degree ; } if ( degreeSum % 2 != 0 ) { return false ; } copy . sort ( Collections . reverseOrder ( ) ) ; for ( int k = 1 ; k < L ; ++ k ) { int sum = 0 ; for ( int i = 0 ; i < k ; ++ i ) { sum += copy . get ( i ) ; } int comp = 0 ; for ( int j = k ; j < L ; ++ j ) { comp += min ( k , copy . get ( j ) ) ; } if ( sum > k * ( k - 1 ) + comp ) { return false ; } } return true ; }
all valid distributions must be graphical . this is tested using erdos - gallai condition on degree distribution graphicality . ( see blitzstein - diaconis paper )
