set_edge_attrs_ws: Set edge attributes with an edge selection

View source: R/set_edge_attrs_ws.R

set_edge_attrs_wsR Documentation

Set edge attributes with an edge selection

Description

From a graph object of class dgr_graph or an edge data frame, set edge attribute properties for one or more edges.

This function makes use of an active selection of edges (and the function ending with ⁠_ws⁠ hints at this).

Selections of edges can be performed using the following selection (⁠select_*()⁠) functions: select_edges(), select_last_edges_created(), select_edges_by_edge_id(), or select_edges_by_node_id().

Selections of edges can also be performed using the following traversal (⁠trav_*()⁠) functions: trav_out_edge(), trav_in_edge(), trav_both_edge(), or trav_reverse_edge().

Usage

set_edge_attrs_ws(graph, edge_attr, value)

Arguments

graph

A graph object of class dgr_graph.

edge_attr

The name of the attribute to set.

value

The value to be set for the chosen attribute for the edges in the current selection.

Value

A graph object of class dgr_graph.

See Also

Other Edge creation and removal: add_edge_clone(), add_edge_df(), add_edges_from_table(), add_edges_w_string(), add_edge(), add_forward_edges_ws(), add_reverse_edges_ws(), copy_edge_attrs(), create_edge_df(), delete_edges_ws(), delete_edge(), delete_loop_edges_ws(), drop_edge_attrs(), edge_data(), join_edge_attrs(), mutate_edge_attrs_ws(), mutate_edge_attrs(), recode_edge_attrs(), rename_edge_attrs(), rescale_edge_attrs(), rev_edge_dir_ws(), rev_edge_dir(), set_edge_attr_to_display(), set_edge_attrs()

Examples

# Create a simple graph
graph <-
  create_graph() %>%
  add_path(n = 6)

# Select specific edges from
# the graph and apply the edge
# attribute `color = blue` to
# those selected edges
graph <-
  graph %>%
  select_nodes_by_id(nodes = 2:4) %>%
  trav_out_edge() %>%
  set_edge_attrs_ws(
    edge_attr = color,
    value = "blue")

# Show the internal edge data
# frame to verify that the
# edge attribute has been set
# for specific edges
graph %>% get_edge_df()


DiagrammeR documentation built on May 31, 2023, 6:14 p.m.