graphneigh               package:spdep               R Documentation

_G_r_a_p_h _b_a_s_e_d _s_p_a_t_i_a_l _w_e_i_g_h_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     Functions return a graph object containing a list with the vertex
     coordinates and the to and from indices defining the edges. The
     helper function 'graph2nb' converts a graph object into a
     neighbour list. The plot functions plot the graph objects.

_U_s_a_g_e:

     gabrielneigh(coords, nnmult=3)
     relativeneigh(coords, nnmult=3)
     soi.graph(tri.nb, coords)
     graph2nb(gob, row.names=NULL,sym=FALSE)
     plot.Gabriel(x, show.points=FALSE, add=FALSE, linecol=par(col), ...)
     plot.relative(x, show.points=FALSE, add=FALSE, linecol=par(col),...)

_A_r_g_u_m_e_n_t_s:

  coords: matrix of region point coordinates

  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

     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(..)'

_D_e_t_a_i_l_s:

     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


              d(x,y) <= min(max(d(x,z),d(y,z))| z in S)


     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


           d(x,y) <= min((d(x,z)^2 + d(y,z)^2)^1/2 |z in S)


     where x,y,z and S are as before. The sphere of influence graph is
     defined for a finite point set S, let r_x be the distance from
     point x to its nearest neighbor in S, and C_x is the circle
     centered on x. Then x and y are SOI neigbors iff C_x and C_y
     intersect in at least 2 places.

_V_a_l_u_e:

     A list of class 'Graph' withte 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.

_A_u_t_h_o_r(_s):

     Nicholas Lewin-Koh nikko@hailmail.net

_R_e_f_e_r_e_n_c_e_s:

     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.

_S_e_e _A_l_s_o:

     'knearneigh', 'dnearneigh', 'knn2nb'

_E_x_a_m_p_l_e_s:

     example(columbus)
     coords <- coordinates(columbus)
     par(mfrow=c(2,2))
     col.tri.nb<-tri2nb(coords)
     col.gab.nb<-graph2nb(gabrielneigh(coords), sym=TRUE)
     col.rel.nb<- graph2nb(relativeneigh(coords), sym=TRUE)
     col.soi.nb<- graph2nb(soi.graph(col.tri.nb,coords), sym=TRUE)
     plot(columbus, border="grey")
     plot(col.tri.nb,coords,add=TRUE)
     title(main="Delaunay Triangulation")
     plot(columbus, border="grey")
     plot(col.gab.nb, coords, add=TRUE)
     title(main="Gabriel Graph")
     plot(columbus, border="grey")
     plot(col.rel.nb, coords, add=TRUE)
     title(main="Relative Neighbor Graph")
     plot(columbus, border="grey")
     plot(col.soi.nb, coords, add=TRUE)
     title(main="Sphere of Influence Graph")
     par(mfrow=c(1,1))
     dx <- rep(0.25*0:4,5)
     dy <- c(rep(0,5),rep(0.25,5),rep(0.5,5), rep(0.75,5),rep(1,5))
     m <- cbind(c(dx, dx, 3+dx, 3+dx), c(dy, 3+dy, dy, 3+dy))
     try(res <- gabrielneigh(m))
     res <- gabrielneigh(m, nnmult=4)
     summary(graph2nb(res))

