public void addVar ( Var var ) { int id = var . getId ( ) ; boolean alreadyAdded = ( 0 <= id && id < vars . size ( ) ) ; if ( alreadyAdded ) { if ( vars . get ( id ) != var ) { throw new IllegalStateException ( "Var id already set, but factor not yet added." ) ; } } else { // Var was not yet in the factor graph. // // Check and set the id. if ( id != - 1 && id != vars . size ( ) ) { throw new IllegalStateException ( "Var id already set, but incorrect: " + id ) ; } var . setId ( vars . size ( ) ) ; // Add the Var. vars . add ( var ) ; if ( bg != null ) { log . warn ( "Discarding BipartiteGraph. This may indicate inefficiency." ) ; } bg = null ; } }
Adds a variable to this factor graph if not already present .