Add a node to an existing graph object
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.
add_node( graph, type = NULL, label = NULL, from = NULL, to = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL )
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
.
Other Node creation and removal:
add_n_node_clones()
,
add_n_nodes_ws()
,
add_n_nodes()
,
add_node_clones_ws()
,
add_node_df()
,
add_nodes_from_df_cols()
,
add_nodes_from_table()
,
colorize_node_attrs()
,
copy_node_attrs()
,
create_node_df()
,
delete_nodes_ws()
,
delete_node()
,
drop_node_attrs()
,
join_node_attrs()
,
layout_nodes_w_string()
,
mutate_node_attrs_ws()
,
mutate_node_attrs()
,
node_data()
,
recode_node_attrs()
,
rename_node_attrs()
,
rescale_node_attrs()
,
set_node_attr_to_display()
,
set_node_attr_w_fcn()
,
set_node_attrs_ws()
,
set_node_attrs()
,
set_node_position()
# 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()
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.