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

add_edge_df

Add edges from an edge data frame to an existing graph object


Description

With a graph object of class dgr_graph, add edges from an edge data frame to that graph.

Usage

add_edge_df(graph, edge_df)

Arguments

graph

A graph object of class dgr_graph.

edge_df

An edge data frame that is created using create_edge_df().

Value

A graph object of class dgr_graph.

See Also

Examples

# Create a graph with 4 nodes
# and no edges
graph <-
  create_graph() %>%
  add_n_nodes(n = 4)

# Create an edge data frame (edf)
edf <-
  create_edge_df(
    from = c(1, 2, 3),
      to = c(4, 3, 1))

# Add the edge data frame to
# the graph object to create
# a graph with both nodes
# and edges
graph <-
  graph %>%
  add_edge_df(
    edge_df = edf)

# Get the graph's edges to
# verify that the edf had
# been added
graph %>%
  get_edges(
    return_type = "vector")

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.