View source: R/make_index_ids.R
make_index_ids | R Documentation |
makes index ids for the provided hy object. These can be used for graph traversal algorithms such that the row number and id are equal.
make_index_ids(x, long_form = FALSE)
## S3 method for class 'data.frame'
make_index_ids(x, long_form = FALSE)
## S3 method for class 'hy'
make_index_ids(x, long_form = FALSE)
x |
data.frame network compatible with hydroloom_names. |
long_form |
logical if TRUE, return will be a long-form version of the
|
list containing named elements: to
: adjacency matrix lengths
:
vector indicating the number of connections from each node, and: to_list
:
a data.frame with an id
, indid
and a toindid
list column. If long_form
= TRUE, return will be a long form data.frame with no list column as in to_list
.
NOTE: the long_form output should be used with caution as indid may not
correspond to row number.
x <- data.frame(id = c(1, 2, 3, 4, 5, 6, 7, 8, 9),
toid = c(2, 3, 4, 5, 0, 7, 8, 9, 4))
make_index_ids(x)
x <- hy(sf::read_sf(system.file("extdata/new_hope.gpkg", package = "hydroloom")))
x <- add_toids(x, return_dendritic = FALSE)
x <- make_index_ids(x)
names(x)
class(x$to)
class(x$lengths)
class(x$to_list)
is.list(x$to_list$toindid)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.