parameters: (size, x, y, z, dx, dy, dz, model, index_map, position_to_rank,
                   arcs)
docstring: Checks if the neighbor is valid, and adds it to the model.
docstring_summary: Checks if the neighbor is valid, and adds it to the model.
docstring_tokens: Checks if the neighbor is valid and adds it to the model .
function: def add_neighbor(size, x, y, z, dx, dy, dz, model, index_map, position_to_rank,
                   arcs):
      """Checks if the neighbor is valid, and adds it to the model."""
      if (x + dx < 0 or x + dx >= size or y + dy < 0 or y + dy >= size or
              z + dz < 0 or z + dz >= size):
          return
      before_index = index_map[(x, y, z)]
      before_rank = position_to_rank[(x, y, z)]
      after_index = index_map[(x + dx, y + dy, z + dz)]
      after_rank = position_to_rank[(x + dx, y + dy, z + dz)]
      move_literal = model.NewBoolVar('')
      model.Add(after_rank == before_rank + 1).OnlyEnforceIf(move_literal)
      arcs.append((before_index, after_index, move_literal))
function_tokens: def add_neighbor ( size , x , y , z , dx , dy , dz , model , index_map , position_to_rank , arcs ) : if ( x + dx < 0 or x + dx >= size or y + dy < 0 or y + dy >= size or z + dz < 0 or z + dz >= size ) : return before_index = index_map [ ( x , y , z ) ] before_rank = position_to_rank [ ( x , y , z ) ] after_index = index_map [ ( x + dx , y + dy , z + dz ) ] after_rank = position_to_rank [ ( x + dx , y + dy , z + dz ) ] move_literal = model . NewBoolVar ( '' ) model . Add ( after_rank == before_rank + 1 ) . OnlyEnforceIf ( move_literal ) arcs . append ( ( before_index , after_index , move_literal ) )