def update_variables(variables, constraints):
    """Updates all variables with their neighboring variables and constraints."""
    for constraint in constraints:
        scope = constraints[constraint].variables
        for var in scope:
            variables[var].add_constraint(constraint)
            variables[var].add_scope(scope)
    return variables