Functions return a graph object containing a list with the vertex coordinates and the to and from indices defining the edges. Some/all of these functions assume that the coordinates are not exactly regularly spaced. The helper function graph2nb converts a graph object into a neighbour list. The plot functions plot the graph objects.
gabrielneigh(coords, nnmult=3)relativeneigh(coords, nnmult=3)soi.graph(tri.nb, coords, quadsegs=10)graph2nb(gob, row.names=NULL,sym=FALSE)## S3 method for class 'Gabriel'plot(x, show.points=FALSE, add=FALSE, linecol=par(col),...)## S3 method for class 'relative'plot(x, show.points=FALSE, add=FALSE, linecol=par(col),...)
Arguments
coords: matrix of region point coordinates or SpatialPoints object or sfc points object
nnmult: scaling factor for memory allocation, default 3; if higher values are required, the function will exit with an error; example below thanks to Dan Putler
tri.nb: a neighbor list created from tri2nb
quadsegs: number of line segments making a quarter circle buffer, see the nQuadSegs argument in geos_unary
gob: a graph object created from any of the graph funtions
row.names: character vector of region ids to be added to the neighbours list as attribute region.id, default seq(1, nrow(x))
sym: a logical argument indicating whether or not neighbors should be symetric (if i->j then j->i)
x: object to be plotted
show.points: (logical) add points to plot
add: (logical) add to existing plot
linecol: edge plotting colour
...: further graphical parameters as in par(..)
Details
The graph functions produce graphs on a 2d point set that
are all subgraphs of the Delaunay triangulation. The relative neighbor graph is defined by the relation, x and y are neighbors if
where d() is the distance, S is the set of points and z is an arbitrary point in S. The Gabriel graph is a subgraph of the delaunay triangulation and has the relative neighbor graph as a sub-graph. The relative neighbor graph is defined by the relation x and y are Gabriel neighbors if
where x,y,z and S are as before. The sphere of influence graph is defined for a finite point set S, let rx be the distance from point x to its nearest neighbor in S, and Cx is the circle centered on x. Then x and y are SOI neigbors iff Cx and Cy intersect in at least 2 places. From 2016-05-31, Computational Geometry in C code replaced by calls to functions in dbscan and sf; with a large quadsegs= argument, the behaviour of the function is the same, otherwise buffer intersections only closely approximate the original function.
See card for details of nb objects.
Returns
A list of class Graph with the following elements - np: number of input points
from: array of origin ids
to: array of destination ids
nedges: number of edges in graph
x: input x coordinates
y: input y coordinates
The helper functions return an nb object with a list of integer vectors containing neighbour region number ids.
References
Matula, D. W. and Sokal R. R. 1980, Properties of Gabriel graphs relevant to geographic variation research and the clustering of points in the plane, Geographic Analysis, 12(3), pp. 205-222.
Toussaint, G. T. 1980, The relative neighborhood graph of a finite planar set, Pattern Recognition, 12(4), pp. 261-268.
Kirkpatrick, D. G. and Radke, J. D. 1985, A framework for computational morphology. In Computational Geometry, Ed. G. T. Toussaint, North Holland.