1% Generated by roxygen2: do not edit by hand 2% Please edit documentation in R/set_edge_attrs.R 3\name{set_edge_attrs} 4\alias{set_edge_attrs} 5\title{Set edge attribute values} 6\usage{ 7set_edge_attrs(graph, edge_attr, values, from = NULL, to = NULL) 8} 9\arguments{ 10\item{graph}{A graph object of class \code{dgr_graph}.} 11 12\item{edge_attr}{The name of the attribute to set.} 13 14\item{values}{The values to be set for the chosen attribute for the chosen 15edges.} 16 17\item{from}{An optional vector of node IDs from which the edge is outgoing 18for filtering list of nodes with outgoing edges in the graph.} 19 20\item{to}{An optional vector of node IDs from which the edge is incoming for 21filtering list of nodes with incoming edges in the graph.} 22} 23\value{ 24A graph object of class \code{dgr_graph}. 25} 26\description{ 27From a graph object of class \code{dgr_graph}, set edge attribute values for one 28or more edges. 29} 30\examples{ 31# Create a simple graph 32ndf <- 33 create_node_df( 34 n = 4, 35 type = "basic", 36 label = TRUE, 37 value = c(3.5, 2.6, 9.4, 2.7)) 38 39edf <- 40 create_edge_df( 41 from = c(1, 2, 3), 42 to = c(4, 3, 1), 43 rel = "leading_to") 44 45graph <- 46 create_graph( 47 nodes_df = ndf, 48 edges_df = edf) 49 50# Set attribute `color = "green"` 51# for edges `1`->`4` and `3`->`1` 52# in the graph 53graph <- 54 graph \%>\% 55 set_edge_attrs( 56 edge_attr = color, 57 values = "green", 58 from = c(1, 3), 59 to = c(4, 1)) 60 61# Set attribute `color = "blue"` 62# for all edges in the graph 63graph <- 64 graph \%>\% 65 set_edge_attrs( 66 edge_attr = color, 67 values = "blue") 68 69# Set attribute `color = "pink"` 70# for all edges in graph outbound 71# from node with ID value `1` 72graph <- 73 graph \%>\% 74 set_edge_attrs( 75 edge_attr = color, 76 values = "pink", 77 from = 1) 78 79# Set attribute `color = "black"` 80# for all edges in graph inbound 81# to node with ID `1` 82graph <- 83 graph \%>\% 84 set_edge_attrs( 85 edge_attr = color, 86 values = "black", 87 to = 1) 88 89} 90\seealso{ 91Other Edge creation and removal: 92\code{\link{add_edge_clone}()}, 93\code{\link{add_edge_df}()}, 94\code{\link{add_edges_from_table}()}, 95\code{\link{add_edges_w_string}()}, 96\code{\link{add_edge}()}, 97\code{\link{add_forward_edges_ws}()}, 98\code{\link{add_reverse_edges_ws}()}, 99\code{\link{copy_edge_attrs}()}, 100\code{\link{create_edge_df}()}, 101\code{\link{delete_edges_ws}()}, 102\code{\link{delete_edge}()}, 103\code{\link{delete_loop_edges_ws}()}, 104\code{\link{drop_edge_attrs}()}, 105\code{\link{edge_data}()}, 106\code{\link{join_edge_attrs}()}, 107\code{\link{mutate_edge_attrs_ws}()}, 108\code{\link{mutate_edge_attrs}()}, 109\code{\link{recode_edge_attrs}()}, 110\code{\link{rename_edge_attrs}()}, 111\code{\link{rescale_edge_attrs}()}, 112\code{\link{rev_edge_dir_ws}()}, 113\code{\link{rev_edge_dir}()}, 114\code{\link{set_edge_attr_to_display}()}, 115\code{\link{set_edge_attrs_ws}()} 116} 117\concept{Edge creation and removal} 118