question: 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 ; }
target:  All valid distributions must be graphical. This is tested using Erdos-Gallai condition on degree distribution graphicality. (see Blitzstein-Diaconis paper)