add_n_nodes: Add one or several unconnected nodes to the graph

Description Usage Arguments Value Examples

View source: R/add_n_nodes.R

Description

Add n new nodes to a graph object of class dgr_graph. Optionally, set node type values for the new nodes.

Usage

1
add_n_nodes(graph, n, type = NULL, label = NULL, ...)

Arguments

graph

a graph object of class dgr_graph.

n

the number of new nodes to add to the graph.

type

an optional character vector that provides group identifiers for the nodes to be added.

label

an optional character object that describes the nodes to be added.

...

optional node attributes supplied as vectors.

Value

a graph object of class dgr_graph.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Create an empty graph and add 5 nodes; these
# nodes will be assigned ID values from `1` to `5`
graph <-
  create_graph() %>%
  add_n_nodes(n = 5)

# Get the graph's nodes
graph %>%
  get_node_ids()
#> [1] 1 2 3 4 5

DiagrammeR documentation built on Sept. 7, 2017, 1:06 a.m.