Check that a hand-built adjacency matrix is a well-formed spatial graph
before passing it to spatial() / spatial_car(): square, finite,
symmetric, zero on the diagonal, 0/1 valued, free of negative weights and of
isolated nodes, and connected. adjacency() runs the same checks on the
graphs it constructs. The spatial constructors refuse a graph with a
missing, non-finite or negative entry.
Usage
check_adjacency(adjacency, ids = NULL)
# S3 method for class 'tulpa_adjacency_check'
print(x, ...)Value
Invisibly, a tulpa_adjacency_check list with the per-check results
(square, finite, symmetric, zero_diag, binary, nonneg,
isolated-node indices, n_components and component_sizes, edge count)
and an overall ok flag. Issues are reported via warning() and printed;
the function does not stop, so every problem surfaces in one pass.
See also
adjacency() to construct a graph, node_index().
Examples
adj <- matrix(0, 4, 4)
for (i in 1:3) adj[i, i + 1] <- adj[i + 1, i] <- 1
check_adjacency(adj)