nb2graph {BARD} | R Documentation |
These functions operate on neighbood lists generated by the spdep package.
nb2graph(nb) neighbors(nb,i,...) neighbors.nb(nb,i,...) n.comp.include(nb,include)
nb |
a neighborhood list generated by the spdep package |
i |
block id |
include |
exlusion list |
... |
additional arguments to pass onto neighbor methods |
These are primarily bard internal functions, exposed for programmers.
Neighbors is a generic method returning a list of indexes of all blocks directly conneccted to those in the supplied blocks id list.
nb2graph converts a spdep neighborhood object into a graph object suitable for use with rbgl
n.comp.exclude is analogous to n.comp.nb
in that it returns the number of connected subgraphs inducd by the neighborhood graph. However, it allows an exlcusion list to be supplied, so that only a subset of the list is examined. This is semantically equivalent to n.comp.nb(subset(nb,i))
but is roughly 10-50x faster.
nb2graph returns a graph object, the others return a vector block ids
Micah Altman Micah_Altman@harvard.edu http://www.hmdc.harvard.edu/micah_altman/
suffolk.map <- importBardShape(file.path(system.file("shapefiles", package="BARD"),"suffolk_tracts")) snb<-suffolk.map$nb neighbors(snb,c(1,2,3)) kplan <- createKmeansPlan(suffolk.map,5) rplan <- createRandomPlan(suffolk.map,5) n.comp.include(snb,rplan==1) n.comp.include(snb,kplan==1)