spatgraph | R Documentation |
Given a spatial point pattern, we compute the edges of a graph (network) for a specified type of edge relationship.
spatgraph( x, type = "geometric", par = NULL, verbose = FALSE, maxR = 0, doDists = FALSE, preGraph = NULL )
x |
Input point pattern object |
type |
Type of the graph |
par |
Parameter(s) for the graph |
verbose |
Print details |
maxR |
Maximum range for edges, helps in large patterns. |
doDists |
Precompute distances? Speeds up some graphs, takes up memory. |
preGraph |
Precomputed graph, taken as a super-graph |
Several edge definitions are supported:
par=numeric>0. Geometric graph, par = connection radius.
par=integer>0. k-nearest neighbours graph, par = k.
Connect two points if ||x-y||<m(x). par=vector giving the m(x_i)'s
Connect two points if ||x-y||<m(x)+m(y). par = vector giving the m(x_i)'s
Gabriel graph. Additional parameter for allowing par=k
instead of 0 points in the circle.
Minimal spanning tree.
Spheres of Influence.
Radial spanning tree, par=origin of radiation, coordinate vector
Relative neighbourhood graph
Class-Cover-Catch, par=factor vector of point types. The factor vector is converted to integers according to R's internal representation of factors, and the points with type 1 will be the target. Use relevel to change the target.
The parameter 'maxR' can be given to bring n^3 graphs closer to n^2. k-nearest neighbours will warn if maxR is too small (<k neighbours for some points), others, like RNG, don't so be careful.
Voronoi diagram aka Delaunay triangulation is not supported as other R-packages can do it, see. e.g. package 'deldir'.
# basic example x <- matrix(runif(50*2), ncol=2) g <- spatgraph(x, "knn", par=3) plot(g, x) # bigger example xb <- matrix(runif(5000*2), ncol=2) gb <- spatgraph(xb, "RNG", maxR=0.1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.