private boolean domainsOverlap ( TableFactor f1 , TableFactor f2 ) { for ( int n1 : f1 . neighborIndices ) { for ( int n2 : f2 . neighborIndices ) { if ( n1 == n2 ) return true ; } } return false ; }
Just a quick inline to check if two factors have overlapping domains . Since factor neighbor sets are super small this n^2 algorithm is fine .