# `ExVrp.Neighbourhood`
[🔗](https://github.com/sephianl/ex_vrp/blob/v0.4.2/lib/ex_vrp/neighbourhood.ex#L1)

Computes granular neighbourhood for local search.

Uses Nx for efficient tensor operations, directly porting PyVRP's
compute_neighbours algorithm from pyvrp/search/neighbourhood.py.

## Example

    # Get neighbours for a problem
    {:ok, problem_data} = ExVrp.Native.create_problem_data(model)
    params = ExVrp.NeighbourhoodParams.new(num_neighbours: 40)
    neighbours = ExVrp.Neighbourhood.compute_neighbours(problem_data, params)

    # neighbours is a list of lists:
    # - neighbours[0..num_depots-1] are empty (depots have no neighbours)
    # - neighbours[i] for clients contains the k nearest client indices

# `compute_neighbours`

```elixir
@spec compute_neighbours(reference(), ExVrp.NeighbourhoodParams.t()) :: [[integer()]]
```

Computes neighbours for each location.

Returns list of lists: neighbours[location] = [neighbour_indices...]
Depots get empty lists.

## Parameters

- `problem_data` - Reference to ProblemData resource
- `params` - NeighbourhoodParams configuration

## Returns

A list of lists where:
- The first `num_depots` entries are empty lists
- Each client entry contains the indices of its k nearest neighbours

---

*Consult [api-reference.md](api-reference.md) for complete listing*
