### 2.9. Finding minimum and maximum

2.9.1. `igraph_vector_min` — Smallest element of a vector.
2.9.2. `igraph_vector_max` — Gives the maximum element of the vector.
2.9.3. `igraph_vector_which_min` — Index of the smallest element.
2.9.4. `igraph_vector_which_max` — Gives the position of the maximum element of the vector.
2.9.5. `igraph_vector_minmax` — Minimum and maximum elements of a vector.
2.9.6. `igraph_vector_which_minmax` — Index of the minimum and maximum elements

#### 2.9.1. `igraph_vector_min` — Smallest element of a vector.

```igraph_real_t igraph_vector_min(const igraph_vector_t* v);
```

The vector must be non-empty.

Arguments:

 `v`: The input vector.

Returns:

 The smallest element of `v`.

Time complexity: O(n), the number of elements.

#### 2.9.2. `igraph_vector_max` — Gives the maximum element of the vector.

```igraph_real_t igraph_vector_max(const igraph_vector_t* v);
```

If the size of the vector is zero, an arbitrary number is returned.

Arguments:

 `v`: The vector object.

Returns:

 The maximum element.

Time complexity: O(n), n is the size of the vector.

#### 2.9.3. `igraph_vector_which_min` — Index of the smallest element.

```long int igraph_vector_which_min(const igraph_vector_t* v);
```

The vector must be non-empty. If the smallest element is not unique, then the index of the first is returned.

Arguments:

 `v`: The input vector.

Returns:

 Index of the smallest element.

Time complexity: O(n), the number of elements.

#### 2.9.4. `igraph_vector_which_max` — Gives the position of the maximum element of the vector.

```long int igraph_vector_which_max(const igraph_vector_t* v);
```

If the size of the vector is zero, -1 is returned.

Arguments:

 `v`: The vector object.

Returns:

 The position of the first maximum element.

Time complexity: O(n), n is the size of the vector.

#### 2.9.5. `igraph_vector_minmax` — Minimum and maximum elements of a vector.

```int igraph_vector_minmax(const igraph_vector_t *v,
igraph_real_t *min, igraph_real_t *max);
```

Handy if you want to have both the smallest and largest element of a vector. The vector is only traversed once. The vector must by non-empty.

Arguments:

 `v`: The input vector. It must contain at least one element. `min`: Pointer to a base type variable, the minimum is stored here. `max`: Pointer to a base type variable, the maximum is stored here.

Returns:

 Error code.

Time complexity: O(n), the number of elements.

#### 2.9.6. `igraph_vector_which_minmax` — Index of the minimum and maximum elements

```int igraph_vector_which_minmax(const igraph_vector_t *v,
long int *which_min, long int *which_max);
```

Handy if you need the indices of the smallest and largest elements. The vector is traversed only once. The vector must to non-empty.

Arguments:

 `v`: The input vector. It must contain at least one element. `which_min`: The index of the minimum element will be stored here. `which_max`: The index of the maximum element will be stored here.

Returns:

 Error code.

Time complexity: O(n), the number of elements.