# Adjacent2Vertex

The `Adjacent2Vertex`

map is closely related to the `Adjacent`

map. Instead of mapping edges to vertices that together form positively oriented triangles, we map vertices to all edges that will form a positively oriented triangle with that vertex. The definition is simply via a `Dict`

:

```
struct Adjacent2Vertex{I,Es,E}
adjacent2vertex::Dict{I,Es}
function Adjacent2Vertex{I,Es,E}() where {I,Es,E}
D = Dict{I,Es}()
TA2V = new{I,Es,E}(D)
return TA2V
end
Adjacent2Vertex(adj2v::Dict{I,Es}) where {I,Es} = new{I,Es,edge_type(Es)}(adj2v)
end
```

A complete list of methods used for working with this struct, along with the struct's docstring itself, is shown below.

`DelaunayTriangulation.Adjacent2Vertex`

— Type`Adjacent2Vertex{I, Es, E}`

Struct for storing adjacency relationships for mapping vertices to all other edges that together form a positively oriented triangle in an associated triangulation. The type `I`

is the integer type used, `Es`

is the type used for representing a collection of edges, and `E`

is the type for a single edge.

See the docs for a description of how boundary edges are handled.

See also `Adjacent`

.

**Fields**

`adjacent2vertex::Dict{I, Es}`

The `Dict`

used for storing the vertices (the keys) and the associated collection of edges (the values). In particular, if `w`

is a vertex, then `(u, v, w)`

is a positively oriented triangle for each `(u, v)`

in `adjacent2vertex[w]`

.

**Constructors**

The adjacent2vertex map can be constructed in two ways:

`Adjacent2Vertex{I,Es,E}()`

Creates an empty map.

`Adjacent2Vertex(adj2v::Dict{I,E}) where {I,Es}`

Creates an adjacent2vertex map from an existing `Dict`

. The type `E`

is obtained from `edge_type`

`(Es)`

.

**Extended help**

You should not work with the `adjacent2vertex`

field directory. We provide the following functions for working with `Adjacent2Vertex`

, where `adj2v`

denotes an `Adjacent2Vertex{I,Es,E}`

type. (Type information in the function signatures is omitted.)

**Accessors**

`get_adjacent2vertex(adj2v)`

`get_adjacent2vertex(adj2v, w)`

**Mutators**

`add_adjacent2vertex!(adj2v, w, uv)`

or`add_adjacent2vertex!(adj2v, w, u, v)`

`delete_adjacent2vertex!(adj2v, w, uv)`

or`delete_adjacent2vertex!(adj2v, w, u, v)`

`delete_adjacent2vertex!(adj2v, w)`

`add_triangle!(adj2v, i, j, k)`

or`add_triangle!(adj2v, T)`

`add_triangle!(adj2v, T...)`

`delete_triangle!(adj2v, i, j, k)`

or`delete_triangle!(adj2v, T)`

`delete_triangle!(adj2v, T...)`

`clear_empty_keys!(adj2v)`

**Iteration**

You can also iterate over `Adjacent2Vertex`

maps the same way as you would with a `Dict`

, e.g. if `adj`

is a corresponding `Adjacent`

map,

```
for (vertex, edge_list) in adj2v
for edge in each_edge(edge_list)
get_adjacent(adj, edge) == vertex
end
end
```

`DelaunayTriangulation.get_adjacent2vertex`

— Method`get_adjacent2vertex(adj2v::Adjacent2Vertex)`

Returns the `adjacent2vertex`

field from the adjacent2vertex map `adj2v`

.

`DelaunayTriangulation.get_adjacent2vertex`

— Method`get_adjacent2vertex(adj2v::Adjacent2Vertex, w)`

Given the adjacent2vertex map `adj2v`

and a vertex `w`

, returns the set of edges associated with the vertex `w`

, i.e. the set of edges `(u, v)`

such that `(u, v, w)`

is a positively oriented triangle in the underlying triangulation.

`DelaunayTriangulation.add_adjacent2vertex!`

— Method```
add_adjacent2vertex!(adj2v::Adjacent2Vertex{I,Es,E}, w, uv) where {I,Es,E}
add_adjacent2vertex!(adj2v::Adjacent2Vertex{I,Es,E}, w, u, v) where {I,Es,E}
```

Given the adjacent2vertex map `adj2v`

, a vertex `w`

, and an edge `(u, v)`

, adds the edge `(u, v)`

into the set of edges associated with the vertex `w`

in the map.

`DelaunayTriangulation.delete_adjacent2vertex!`

— Method```
delete_adjacent2vertex!(adj2v::Adjacent2Vertex, w, uv)
delete_adjacent2vertex!(adj2v::Adjacent2Vertex{I,Es,E}, w, u, v) where {I,Es,E}
```

Given the adjacent2vertex map `adj2v`

, a vertex `w`

, and an edge `(u, v)`

, deletes the edge `(u, v)`

from the set of edges associated with the vertex `w`

in the map.

`DelaunayTriangulation.delete_adjacent2vertex!`

— Method`delete_adjacent2vertex!(adj2v::Adjacent2Vertex, w)`

Given the adjacent2vertex map `adj2v`

and a vertex `w`

, deletes the key `w`

from the map.

`DelaunayTriangulation.add_triangle!`

— Method`add_triangle!(adj2v::Adjacent2Vertex, i, j, k)`

Given an adjacent2vertex map `adj2v`

and indices `(i, j, k)`

representing some triangle, adds that triangle from the map. In particular, adds the edges `(i, j)`

, `(j, k)`

, and `(k, i)`

into the set of edges associated with the vertices `k`

, `i`

, and `j`

, respectively, in the map.

`DelaunayTriangulation.add_triangle!`

— Method`add_triangle!(adj::Adjacent2Vertex, T...)`

Given an adjacent map `adj2v`

and triangles `T...`

, adds the triangles into `adj2v`

. See also `add_triangle!`

.

`DelaunayTriangulation.delete_triangle!`

— Method`delete_triangle!(adj2v::Adjacent2Vertex, i, j, k)`

Given an adjacent2vertex map `adj2v`

and indices `(i, j, k)`

representing some triangle, deletes that triangle from the map. In particular, deletes the edges `(i, j)`

, `(j, k)`

, and `(k, i)`

from the set of edges associated with the vertices `k`

, `i`

, and `j`

, respectively, from the map.

`DelaunayTriangulation.delete_triangle!`

— Method`delete_triangle!(adj::Adjacent2Vertex, T...)`

Given an adjacent2vertex map `adj2v`

and triangles `T...`

, deletes the triangles from `adj2v`

. See also `delete_triangle!`

.

`DelaunayTriangulation.clear_empty_keys!`

— Method`clear_empty_keys!(adj2v::Adjacent2Vertex)`

Given an `Adjacent2Vertex`

map `adj2v`

, removes any keys that map to empty sets.