Skip to content

Commit

Permalink
Add basic validation as suggested by tsdye (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeroe committed Dec 29, 2018
1 parent a94ce9b commit 6404c76
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
21 changes: 21 additions & 0 deletions R/graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,25 @@ harris <- function(data, context, relation) {
tibble::tibble(to, from) %>%
drop_na() %>%
return()
}

#' Validate stratigraphic graphs
#'
#' Checks whether a stratigraphic graph is a valid Harris matrix.
#'
#' @param stratgraph A stratigraphic graph.
#' @param warn Display warnings for invalid graphs (Default: `TRUE`).
#'
#' @return `TRUE` or `FALSE`
#' @export
#'
#' @examples
is_valid_harris <- function(stratgraph, warn = TRUE) {
if (!igraph::is.dag(stratgraph)) {
if(warn) warning("Invalid Harris matrix: graph contains cycles")
return(FALSE)
}
else {
return(TRUE)
}
}
19 changes: 19 additions & 0 deletions man/is_valid_harris.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6404c76

Please sign in to comment.