Add a node to the network. Takes the node id (string), the node type (string), and the node level (int).

add_node(sbm, id, type = NULL, show_messages = TRUE)

Arguments

sbm

sbm_network object as created by new_sbm_network.

id

Unique identifying name for node.

type

Type of node (string). This is used to distinguish multipartite networks. E.g. "person", or "publication", etc..

show_messages

Should function inform of its actions such as when a model already exists so no changes are made?

Value

An S3 object of class sbm_network. For details see new_sbm_network section "Class structure."

See also

Examples

# Start with network with 5 nodes. net <- sim_random_network(n_nodes = 5, prob_of_edge = 1, setup_model = TRUE) # Verify nodes net$nodes
#> # A tibble: 5 x 3 #> id block type #> <chr> <chr> <chr> #> 1 node_1 node node #> 2 node_2 node node #> 3 node_3 node node #> 4 node_4 node node #> 5 node_5 node node
net %>% state()
#> NULL
# Add two nodes net <- net %>% add_node('new_node1', type = 'node') %>% add_node('new_node2', type = 'node') # New nodes are added to node data and state net$nodes
#> # A tibble: 7 x 3 #> id block type #> <chr> <chr> <chr> #> 1 node_1 node node #> 2 node_2 node node #> 3 node_3 node node #> 4 node_4 node node #> 5 node_5 node node #> 6 new_node1 NA node #> 7 new_node2 NA node
net %>% state()
#> NULL