## Individual Edges

Edges are assumed to take the form `(i, j)`

, with customisation available for how we represent `(i, j)`

. The following methods are used, where we first list the methods that must be defined and then methods that extend these former methods.

### Necessary Methods

`DelaunayTriangulation.construct_edge`

— Function`construct_edge(::Type{E}, i, j) where {E}`

Constructs an edge with indices `(i, j)`

with the type `E`

. The following methods are currently defined:

```
construct_edge(::Type{NTuple{2, I}}, i, j) where {I}
construct_edge(::Type{A}, i, j) where {I,A<:AbstractVector}
```

You can extend this function as you need, ensuring you define it on the type rather than on an instance of the type.

`DelaunayTriangulation.initial`

— Function`initial(e::E)`

Given an edge `e`

, returns the index for the initial point. The following methods are currently defined:

```
initial(e::NTuple{2,I}) where {I}
initial(e::A) where {I,A<:AbstractVector{I}}
```

You can extend this function as you need.

`DelaunayTriangulation.terminal`

— Function`terminal(e::E)`

Given an edge `e`

, returns the index for the terminal point. The following methods are currently defined:

```
terminal(e::NTuple{2,I}) where {I}
terminal(e::A) where {I,A<:AbstractVector{I}}
```

You can extend this function as you need.

### Generic Methods

`DelaunayTriangulation.edge_indices`

— Function`DelaunayTriangulation.reverse_edge`

— Function`reverse_edge(e)`

Given an edge `e`

, returns `(terminal(e), initial(e))`

.

`DelaunayTriangulation.compare_unoriented_edge`

— Function`compare_unoriented_edge(u, v)`

Compares two edges `u`

and `v`

to see if they are the same edge, regardless of the orientation.

## Collection of Edges

A collection of edges simply stores many edges, and this collection must be mutable so that edges can be deleted added and deleted. The following methods are used, where we first list the methods that must be defined and then methods that extend these former methods.

### Necessary Methods

`DelaunayTriangulation.initialise_edges`

— Function`initialise_edges(::Type{S})`

For a given type `S`

for some collection (e.g. a `Set`

), returns an empty instance of that collection. The only method defined is

```
initialise_edges(::Type{S}) where {E, S <: Set{E}}
initialise_edges(::Type{A}) where {E, A <: AbstractVector{E}}
```

which returns a `Set{E}()`

or a `A()`

, respectively. You can extend this function as you need, making sure you extend it for the type rather than for instances of that type.

`DelaunayTriangulation.edge_type`

— Function`edge_type(::Type{S}) where {S}`

For a given type `S`

representing a collection of edges, returns the type of triangle used inside `S`

, e.g. `NTuple{2, Int}`

if `S = Set{NTuple{2, Int}}`

. The only methods defined are

```
edge_type(::Type{S}) where {E,S<:Set{E}}
edge_type(::Type{A}) where {E,A<:AbstractVector{E}}
```

which return `E`

. You can extend this function as you need, making sure you extend it for the type rather than for instances of that type.

`DelaunayTriangulation.num_edges`

— Function`num_edges(E::S) where {S}`

Given a collection of edges `E`

, returns the number of edges in `E`

. The only method currently defined is

```
num_edges(E::Set)
num_edges(E::AbstractVector)
```

which returns `length(E)`

. You can extend this function as you need.

`DelaunayTriangulation.contains_edge`

— Function`contains_edge(e::E, Es::S) where {E, S}`

Given a collection of edges `Es`

of type `S`

, containing edges of type `E`

, checks if `Es`

includes the edge `e`

, returning `true`

if so. The methods currently defined are

```
contains_edge(e::E, Es::Set{E}) where {E}
contains_edge(e::E, Es::A) where {E,A<:AbstractVector{E}}
contains_edge(i, j, Es::E)
```

The first two methods simply return `e ∈ E`

, while the latter constructs the edge `e = (i, j)`

of type `edge_type(E)`

and call the first two methods. Only the method `contains_edge(::E, ::Es)`

needs to be extended if you need, the last method makes use of this definition.

`DelaunayTriangulation.add_to_edges!`

— Function`add_to_edges!(E::S, e) where {S}`

Given a collection of edges `E`

, pushes `e`

into it. The only methods currently defined are

```
add_to_edges!(E::Set, e)
add_to_edges!(E::Vector, e)
```

which simply call `push!(E, e)`

. You can extend this function as you need.

`DelaunayTriangulation.delete_from_edges!`

— Function`delete_from_edges!(E::S, e::F) where {S}`

Given a collection of edges `E`

of type `S`

, containing edges of type `F`

, deletes the edge `e`

from `E`

. The methods currently defined are

```
delete_from_edges!(E::Set{F}, T::F) where {F}
delete_from_edges!(Es::A, e::E) where {E, A<:AbstractVector{E}}
```

which just calls `delete!`

on `E`

in the first case, or `filter!`

in the second case. This is the form of the function that needs to be extended. We also define

`delete_from_edges!(Es::E, i::Integer, j::Integer) where {E}`

which constructs the edge `(i, j)`

and then deletes it from `Es`

, calling the methods above. You do not need to extend this last method.

`DelaunayTriangulation.each_edge`

— Function`each_edge(E::F) where {F}`

For a given collection of edges `E`

, returns an iterator that goes over each edge in the collection. The methods currently defined are

```
each_edge(E::Set)
each_edge(E::AbstractMatrix)
each_edge(E::AbstractVector)
```

with the first and third methods simply returning `E`

, and the second returning `eachcol(E)`

. You can extend this function as you need.

### Generic Methods

`DelaunayTriangulation.add_edge!`

— Function`add_edge!(E, e...)`

Given a collection of edges `E`

, adds all the triangles `e...`

into it. To extend this method to other collections, see `add_to_edges!`

.

```
add_edge!(tri::Triangulation, segment; rng::AbstractRNG=Random.default_rng())
add_edge!(tri::Triangulation, i, j; rng::AbstractRNG=Random.default_rng())
```

Adds the edge `segment = (i, j)`

into the triangulation `tri`

.

`DelaunayTriangulation.delete_edge!`

— Function`delete_edge!(E, e...)`

Given a collection of edges `E`

, deletes all the edges `e...`

from it. To extend this method to other collections, see `delete_from_edges!`

.

`DelaunayTriangulation.random_edge`

— Function`random_edge(E)`

Returns a random edge from edge set `E`

.

`DelaunayTriangulation.is_empty`

— Function`is_empty(E)`

Tests if the edge set `E`

is empty.