relative_neighborhood_graph

relative_neighborhood_graph#

graph_tool.generation.relative_neighborhood_graph(points)[git][source]#

Return the relative neighborhood graph of a set of points.

Parameters:
pointstwo-dimensional array

Coordinates of the points, as rows, without duplicates.

Returns:
gGraph

The relative neighborhood graph.

posVertexPropertyMap

Positions of the vertices.

See also

beta_skeleton

\(\beta\)-skeletons

gabriel_graph

Gabriel graph

Notes

In the relative neighborhood graph [toussaint-relative-1980], two points \(p\) and \(q\) are adjacent if there is no other point \(r\) with \(d(p, r) < d(p, q)\) and \(d(q, r) < d(p, q)\). It is connected and contains the euclidean minimum spanning tree. It is the lune-based \(\beta\)-skeleton for \(\beta = 2\) (see beta_skeleton(), which describes the algorithm), but with an open region, so that the vertices of an equilateral triangle are all adjacent.

References

[toussaint-relative-1980]

Godfried T. Toussaint, “The relative neighbourhood graph of a finite planar set”, Pattern Recognition 12, 261-268 (1980), DOI: 10.1016/0031-3203(80)90066-7 [sci-hub, @tor]

Examples

>>> points = np.random.random((1000, 2))
>>> g, pos = gt.relative_neighborhood_graph(points)
>>> print(g.num_edges())
1237

A smaller instance is drawn as follows:

>>> points = np.random.random((200, 2))
>>> g, pos = gt.relative_neighborhood_graph(points)
>>> gt.graph_draw(g, pos=pos,
...               output="relative_neighborhood_graph-small.pdf")
<...>
../_images/relative_neighborhood_graph-small.png

Relative neighborhood graph of 200 random points in the unit square.#