check_hy_graph {hydroloom}R Documentation

Check hy Graph

Description

check that a id toid graph doesn't contain localized loops.

Usage

check_hy_graph(x, loop_check = FALSE)

Arguments

x

data.frame network compatible with hydroloom_names.

loop_check

logical if TRUE, the entire network is walked from top to bottom searching for loops. This loop detection algorithm visits a node in the network only once all its upstream neighbors have been visited. A complete depth first search is performed at each node, searching for paths that lead to an already visited (upstream) node. This algorithm is often referred to as "recursive depth first search".

Value

if no localized loops are found, returns TRUE. If localized loops are found, problem rows with a row number added.

Examples

# notice that row 4 (id = 4, toid = 9) and row 8 (id = 9, toid = 4) is a loop.
test_data <- data.frame(id = c(1, 2, 3, 4, 6, 7, 8, 9),
                      toid = c(2, 3, 4, 9, 7, 8, 9, 4))
check_hy_graph(test_data)


[Package hydroloom version 1.0.2 Index]