# Graph

To make it possible to iterate over all points that share an edge with a given vertex, we have a Graph struct that we define as follows:

struct Graph{I}
graph::UndirectedGraph{I}
function Graph{I}() where {I}
G = UndirectedGraph{I}()
return new{I}(G)
end
Graph() = Graph{Int}()
Graph(G::UndirectedGraph{I}) where {I} = new{I}(G)
end

Note that this graph is undirected.

DelaunayTriangulation.GraphType
Graph{I}

Struct for storing neighbourhood relationships that map vertices to all other vertices that share an edge with that vertex. The type I is the integer type.

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

Fields

• graph::UndirectedGraph{I}

The UndirectedGraph that maps a vertex u to a list of edges, V, such that (u, v) is an edge of the triangulation for each v in V.

Extended help

You should not work with the graph field directly. We provide the following functions for working with Graph, where G denotes a Graph{I} type. (Type information in the function signatures is omitted.)

Accessors

• get_graph(G)
• get_vertices(G)
• each_vertex(G)
• get_edges(G)
• get_neighbours(G)
• get_neighbours(G, u)

Mutators

• add_vertex!(G, u...)
• add_neighbour!(G, u, v...)
• add_triangle!(G, i, j, k) or add_triangle!(G, T)
• add_triangle!(G, T...)
• delete_triangle!(G, i, j, k) or delete_triangle!(G, T)
• delete_triangle!(G, T...)
• delete_neighbour!(G, u, v...)
• delete_vertex!(G, u...)
• delete_boundary_vertices_from_graph!(G)
• clear_empty_points!(G)

Miscellaneous

• num_edges(G)
• num_neighbours(G, u)
• num_vertices(G)
• has_vertex(G, u)
• has_boundary_vertices(G)
DelaunayTriangulation.num_edgesMethod
num_edges(G::Graph)

Returns the number of edges G. The edges (i, j) and (j, i) will only be counted once.

DelaunayTriangulation.add_triangle!Method
add_triangle!(G::Graph, i, j, k)

Given a graph G, adds the triangle (i, j, k) into G. In particular, the indices (i, j, k) are added into G, and the indices are all in each other's neighbourhoods.

DelaunayTriangulation.delete_triangle!Method
delete_triangle!(G::Graph, i, j, k)

Given a graph G, deletes the triangle (i, j, k) deletes G. In particular, the indices (i, j, k) will no longer be neighbours of each other.

Note

Be careful with using this function - you could have a triangle (j, i, ℓ), say, which will also be affected since the graph is undirected. Note also that the vertices (i, j, k) will not be removed - only the neighbourhoods are affected.

DelaunayTriangulation.delete_neighbour!Method
delete_neighbour!(G::Graph, u, v...)

Given a graph G and a vertex u, deletes the vertices v... from the neighbourhood of u.