R/remove_edge.R

Defines functions remove_edge

Documented in remove_edge

#' Remove an edge
#'
#' @description Remove the edge between \code{a} and \code{b}
#'
#' @param gr tidygraph graph object
#' @param a,b indices of the two nodes connected by the edge to remove
#'
#' @return a tidygraph graph object without the edge
#'
#' @examples
#' set.seed(0)
#' plot(remove_edge(tidygraph::create_ring(3), 1, 2))
#'
#' @importFrom tidygraph %E>%
#' @export remove_edge
remove_edge <- function(gr, a, b) {
    gr %E>%
        tidygraph::filter(!tidygraph::edge_is_between(a, b, ignore_dir = TRUE))
}
jhrcook/wext documentation built on May 17, 2021, 1:19 a.m.