csg2 | R Documentation |
csg2
, lcsg2
, and scsg2
construct
connected subgraphs. These functions are not intended
for users.
nn
contains a list of nearest
neighbors for each region. idx
is a
vector of possible vertices being considered as a
subgraph. w
is a connectivity matrix relating the
N vertices. w[i,j] = 1
if vertices i and j are
connected, i.e., if they share an edge. The dimensions of
w
are N times k
, where k =
length(idx)
. While the rows of w
contain
adjacency information for all N vertices, only the
idx
columns of the complete adjacency matrix are
used in w
. See Details for discussion of
scsg
.
csg2(cz, cnn, cw)
lcsg2(lcz, cnn, cw)
scsg2(
nn,
w,
idx = seq_along(nn),
nlevel = NULL,
verbose = FALSE,
logical = FALSE
)
cz |
A logical vector representing the current subgraph. |
cnn |
The indices of the neighbors of the current vertex. |
cw |
A binary adjacency matrix for the neighbors of the current vertex. |
lcz |
A list of current zones (in the form of logical vectors). |
nn |
A list of the nearest neighbors for each vertex (region). |
w |
A binary adjacency matrix indicating connected neighbors. |
idx |
A vector of vertices for which to construct the set of connected subgraphs. |
nlevel |
The maximum size of each subgraph. |
verbose |
A logical value indicating whether descriptive messages should be provided. Default is
|
logical |
A logical value indicating whether a list of logical vectors should be returned. The default is |
scsg2
performs a sequence of lcsg2
calls.
Starting with lcz == list(idx[1])
, scsg
keeps iteratively building more connected subsgraphs by
perfoming something like: lcz1 = list(idx[1]). lcz2 =
lcsg2(lcz1, ...). lcz3 = lcsg2(lcz2, ...). This is
done until there are no more connected subgraphs among
the elements of idx
.
A list with all possible connected subgraphs based on the user-provided parameters.
data(nydf)
data(nyw)
# determine 50 nn of region 1 for NY data
coords <- as.matrix(nydf[, c("longitude", "latitude")])
nn3 <- knn(coords, longlat = TRUE, k = 3)
z1 <- scsg2(nn3, nyw)
z2 <- flex.zones(coords, nyw, k = 3, longlat = TRUE)
all.equal(z1, z2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.