check_contiguity {geomander} | R Documentation |
Check Contiguity by Group
Description
Identify contiguous sets of units and numbers each set. Can be extended to repeat the procedure within a subgeography.
Usage
check_contiguity(adj, group)
cct(adj, group)
ccm(adj, group)
Arguments
adj |
adjacency list |
group |
array of group identifiers. Typically district numbers or county names. Defaults to 1 if no input is provided, checking that the adjacency list itself is one connected component. |
Details
Given a zero-indexed adjacency list and an array of group identifiers, this
returns a tibble which identifies the connected components. The three columns
are group
for the inputted group, group_number
which uniquely identifies each
group as a positive integer, and component
which identifies the connected
component number for each corresponding entry of adjacency and group. If everything
is connected within the group, then each element of component
will be 1
.
Otherwise, the largest component is given the value 1
, the next largest 2
,
and so on.
If nothing is provided to group, it will default to a vector of ones, checking if the adjacency graph is connected.
cct()
is shorthand for creating a table of the component values. If everything
is connected within each group, it returns a value of 1. In general, it returns
a frequency table of components.
ccm()
is shorthand for getting the maximum component value. It returns the
maximum number of components that a group is broken into.
This returns 1 if each group is connected. #'
Value
tibble with contiguity indicators. Each row is the units of adj
. Columns include
-
group
Values of the inputtedgroup
argument. Ifgroup
is not specified, then all values will be 1. -
component
A number for each contiguous set of units within agroup
. If all units within agroup
are contiguous, all values are 1. If there are two sets, each discontiguous with the other, the larger one will be numbered 1 and the smaller one will be numbered as 2.
Examples
data(checkerboard)
adj <- adjacency(checkerboard)
# These each indicate the graph is connected.
check_contiguity(adj) # all contiguous
# If there are two discontiguous groups, there will be 2 values of `component`
cct(adj)
ccm(adj)