| check_adjacency | R Documentation |
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.
check_adjacency(adjacency, ids = NULL)
## S3 method for class 'tulpa_adjacency_check'
print(x, ...)
adjacency |
A matrix (dense or sparse |
ids |
Optional cell identifiers; if supplied, their length must match
|
x |
A |
... |
Ignored. |
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.
adjacency() to construct a graph, node_index().
adj <- matrix(0, 4, 4)
for (i in 1:3) adj[i, i + 1] <- adj[i + 1, i] <- 1
check_adjacency(adj)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.