add_edges_w_string {DiagrammeR}R Documentation

Add one or more edges using a text string

Description

With a graph object of class dgr_graph, add one or more edges to the graph using a text string. For a directed graph, the string object should be formatted as a series of node ID values as [node_ID_1]->[node_ID_2] separated by a single space. For undirected graphs, -- should replace ->.

Usage

add_edges_w_string(graph, edges, rel = NULL)

Arguments

graph

a graph object of class dgr_graph that is created using create_graph.

edges

a single-length vector with a character string specifying the edges.

rel

an optional vector specifying the relationship between the connected nodes.

Value

a graph object of class dgr_graph.

Examples

library(magrittr)

# Create a graph with 10 nodes
graph <-
  create_graph() %>%
  add_n_nodes(10)

# Add edges between nodes using a character string
graph <-
  graph %>%
  add_edges_w_string(
    "1->2 1->3 2->4 2->5 3->6 3->7 4->8 4->9 5->10")

[Package DiagrammeR version 0.8.4 Index]