is.symmetric.nb            package:spdep            R Documentation

_T_e_s_t _a _n_e_i_g_h_b_o_u_r_s _l_i_s_t _f_o_r _s_y_m_m_e_t_r_y

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

     Checks a neighbours list for symmetry/transitivity (if i is a
     neighbour of j, then j is a neighbour of i). This holds for
     distance and contiguity based neighbours, but not for k-nearest
     neighbours. The helper function 'sym.attr.nb()' calls
     'is.symmetric.nb()' to set the 'sym' attribute if needed, and
     'make.sym.nb' makes a non-symmetric list symmetric by adding
     neighbors. 'is.symmetric.glist' checks a list of general weights
     corresponding to neighbours for symmetry for symmetric neighbours.

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

     is.symmetric.nb(nb, verbose = TRUE, force = FALSE)
     sym.attr.nb(nb)
     make.sym.nb(nb)
     old.make.sym.nb(nb)
     is.symmetric.glist(nb, glist)

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

      nb: an object of class 'nb' with a list of integer vectors
          containing neighbour region number ids.

 verbose: if TRUE prints non-matching pairs

   force: do not respect a neighbours list 'sym' attribute and test
          anyway

   glist: list of general weights corresponding to neighbours

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

     TRUE if symmetric, FALSE if not; is.symmetric.glist returns a
     value with an attribute, "d", indicating for failed symmetry the
     largest failing value.

_N_o_t_e:

     A new version of 'make.sym.nb' by Bjarke Christensen is now
     included. The older version has been renamed 'old.make.sym.nb',
     and their comparison constitutes a nice demonstration of
     vectorising speedup using 'sapply' and 'lapply' rather than loops.
     When any no-neighbour observations are present, 'old.make.sym.nb'
     is used.

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

     Roger Bivand Roger.Bivand@nhh.no

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

     'read.gal'

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

     example(columbus)
     coords <- coordinates(columbus)
     ind <- sapply(slot(columbus, "polygons"), function(x) slot(x, "ID"))
     print(is.symmetric.nb(col.gal.nb, verbose=TRUE, force=TRUE))
     k4 <- knn2nb(knearneigh(coords, k=4), row.names=ind)
     k4 <- sym.attr.nb(k4)
     print(is.symmetric.nb(k4))
     k4.sym <- make.sym.nb(k4)
     print(is.symmetric.nb(k4.sym))

