1% Generated by roxygen2: do not edit by hand 2% Please edit documentation in R/delete_edge.R 3\name{delete_edge} 4\alias{delete_edge} 5\title{Delete an edge from an existing graph object} 6\usage{ 7delete_edge(graph, from = NULL, to = NULL, id = NULL) 8} 9\arguments{ 10\item{graph}{A graph object of class \code{dgr_graph}.} 11 12\item{from}{a node ID from which the edge to be removed is outgoing. If an 13edge ID is provided to \code{id}, then this argument is ignored. There is 14the option to use a node \code{label} value here (and this must 15correspondingly also be done for the \code{to} argument) for defining node 16connections. Note that this is only possible if all nodes have distinct 17\code{label} values set and none exist as an empty string.} 18 19\item{to}{a node ID to which the edge to be removed is incoming. If an edge 20ID is provided to \code{id}, then this argument is ignored. There is the 21option to use a node \code{label} value here (and this must correspondingly 22also be for the \code{from} argument) for defining node connections. Note 23that this is only possible if all nodes have distinct \code{label} values 24set and none exist as an empty string.} 25 26\item{id}{an edge ID of the edge to be removed.} 27} 28\value{ 29A graph object of class \code{dgr_graph}. 30} 31\description{ 32From a graph object of class \code{dgr_graph}, delete an existing edge by 33specifying either: (1) a pair of node IDs corresponding to the edge 34(keeping into consideration the direction of the edge in a directed graph), 35or (2) an edge ID. 36} 37\examples{ 38# Create a graph with 2 nodes 39graph <- 40 create_graph() \%>\% 41 add_n_nodes(n = 2) 42 43# Add an edge 44graph <- 45 graph \%>\% 46 add_edge( 47 from = 1, 48 to = 2) 49 50# Delete the edge 51graph <- 52 graph \%>\% 53 delete_edge( 54 from = 1, 55 to = 2) 56 57# Get the count of edges in the graph 58graph \%>\% count_edges() 59 60# Create an undirected graph with 61# 2 nodes and an edge 62graph_undirected <- 63 create_graph(directed = FALSE) \%>\% 64 add_n_nodes(n = 2) \%>\% 65 add_edge( 66 from = 1, 67 to = 2) 68 69# Delete the edge; the order of node ID 70# values provided in `from` and `to` 71# don't matter for the undirected case 72graph_undirected \%>\% 73 delete_edge( 74 from = 2, 75 to = 1) \%>\% 76 count_edges() 77 78# The undirected graph has a single 79# edge with ID `1`; it can be 80# deleted by specifying `id` 81graph_undirected \%>\% 82 delete_edge(id = 1) \%>\% 83 count_edges() 84 85# Create a directed graph with 2 86# labeled nodes and an edge 87graph_labeled_nodes <- 88 create_graph() \%>\% 89 add_n_nodes( 90 n = 2, 91 label = c("one", "two")) \%>\% 92 add_edge( 93 from = "one", 94 to = "two") 95 96# Delete the edge using the node 97# labels in `from` and `to`; this 98# is analogous to creating the 99# edge using node labels 100graph_labeled_nodes \%>\% 101 delete_edge( 102 from = "one", 103 to = "two") \%>\% 104 count_edges() 105 106} 107\seealso{ 108Other Edge creation and removal: 109\code{\link{add_edge_clone}()}, 110\code{\link{add_edge_df}()}, 111\code{\link{add_edges_from_table}()}, 112\code{\link{add_edges_w_string}()}, 113\code{\link{add_edge}()}, 114\code{\link{add_forward_edges_ws}()}, 115\code{\link{add_reverse_edges_ws}()}, 116\code{\link{copy_edge_attrs}()}, 117\code{\link{create_edge_df}()}, 118\code{\link{delete_edges_ws}()}, 119\code{\link{delete_loop_edges_ws}()}, 120\code{\link{drop_edge_attrs}()}, 121\code{\link{edge_data}()}, 122\code{\link{join_edge_attrs}()}, 123\code{\link{mutate_edge_attrs_ws}()}, 124\code{\link{mutate_edge_attrs}()}, 125\code{\link{recode_edge_attrs}()}, 126\code{\link{rename_edge_attrs}()}, 127\code{\link{rescale_edge_attrs}()}, 128\code{\link{rev_edge_dir_ws}()}, 129\code{\link{rev_edge_dir}()}, 130\code{\link{set_edge_attr_to_display}()}, 131\code{\link{set_edge_attrs_ws}()}, 132\code{\link{set_edge_attrs}()} 133} 134\concept{Edge creation and removal} 135