Description Usage Arguments Value Examples
With a graph object of class
dgr_graph
, add a new node to the graph.
One can optionally provide node attributes
for the created node. There is also the
option to create edges to and from existing
nodes in the graph. Because new edges can
also be created through this function, there
is the possibility to set edge attributes
for any new graph edges.
1 2 
graph 
a graph object of class

type 
an optional character object that acts as a group identifier for the node to be added. 
label 
an optional character object that describes the node. 
from 
an optional vector containing node IDs from which edges will be directed to the new node. 
to 
an optional vector containing node IDs to which edges will be directed from the new node. 
node_aes 
an optional list of named vectors
comprising node aesthetic attributes. The helper
function 
edge_aes 
an optional list of named vectors
comprising edge aesthetic attributes. The helper
function 
node_data 
an optional list of named vectors
comprising node data attributes. The helper
function 
edge_data 
an optional list of named vectors
comprising edge data attributes. The helper
function 
a graph object of class dgr_graph
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28  # Create an empty graph and add 2 nodes by using
# the `add_node()` function twice
graph <
create_graph() %>%
add_node() %>%
add_node()
# Get a count of all nodes
# in the graph
graph %>%
count_nodes()
# The nodes added were given
# ID values `1` and `2`; obtain
# the graph's node IDs
graph %>%
get_node_ids()
# Add a node with a `type`
# value defined
graph <
graph %>%
add_node(type = "person")
# View the graph's internal
# node data frame (ndf)
graph %>%
get_node_df()

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.