code: public FactorGraph addVariable(String variableName, Variable variable) {
      Preconditions.checkArgument(!getVariables().contains(variableName));
      int varNum = getAllVariables().size() > 0 ? Ints.max(getAllVariables().getVariableNumsArray()) + 1 : 0;
      return addVariableWithIndex(variableName, variable, varNum);
    }
docs: Gets a new {@code FactorGraph} identical to this one, except with
  an additional variable. The new variable is named
  {@code variableName} and has type {@code variable}. Each variable
  in a factor graph must have a unique name; hence {@code this}
  must not already contain a variable named {@code variableName}.