Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

add_forward_edges_ws

Add new edges with identical definitions as with a selection of edges


Description

Add edges in the same direction of one or more edges available as an edge selection in a graph object of class dgr_graph. New graph edges have the same edge definitions as those in the selection except with new edge ID values. There is also the option to assign a common rel grouping to the newly created edges. Upon addition of the edges, the edge selection will be retained for further selection or traversal operations.

Usage

add_forward_edges_ws(graph, rel = NULL)

Arguments

graph

A graph object of class dgr_graph.

rel

An optional string to apply a rel attribute to all newly created edges.

Details

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().

Value

A graph object of class dgr_graph.

See Also

Examples

# Create an empty graph, add 2 nodes
# to it, and create the edge `1->2`
graph <-
  create_graph() %>%
  add_n_nodes(
    n = 2,
    type = "type_a",
    label = c("a_1", "a_2")) %>%
  add_edge(
    from = 1, to = 2, rel = "a")

# Get the graph's edges
graph %>% get_edge_ids()

# Select the edge and create 2
# additional edges with the same
# definition (`1->2`) but with
# different `rel` values (`b` and `c`)
graph <-
  graph %>%
  select_edges() %>%
  add_forward_edges_ws(rel = "b") %>%
  add_forward_edges_ws(rel = "c") %>%
  clear_selection()

# Get the graph's edge data frame
graph %>% get_edge_df()

DiagrammeR

Graph/Network Visualization

v1.0.6.1
MIT + file LICENSE
Authors
Richard Iannone [aut, cre] (<https://orcid.org/0000-0003-3925-190X>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.