Connects two nodes in network (at level 0) by their ids (string).

add_edge(
  sbm,
  from_node,
  to_node,
  from_node_type = NULL,
  to_node_type = NULL,
  show_messages = TRUE,
  type_warning = TRUE
)

Arguments

sbm

sbm_network object as created by new_sbm_network.

from_node

Id of first node in edge

to_node

Id of second node in edge

from_node_type

Type of from_node

to_node_type

Type of to_node

show_messages

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

type_warning

If node types are not specified the model will issue a warning and use the first node in networks type for both. To hide this warning for unipartite networks set this to TRUE.

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 all fully connected net <- sim_random_network(n_nodes = 5, prob_of_edge = 1) # Fully connected network will have 10 edges attr(net, 'n_edges')
#> [1] 10
# Add a new edge between two non-yet-seen nodes net <- net %>% add_edge('new_from_node', 'new_to_node')
#> new_from_node node not in network but has no specified type. Defaulting to node
#> new_to_node node not in network but has no specified type. Defaulting to node
# We have two nodes added to our model attr(net, 'n_nodes')
#> [1] 7
# And one edge attr(net, 'n_edges')
#> [1] 11
# adding an edge between two nodes already in the network net <- net %>% add_edge('new_from_node', 'new_to_node') # Another edge will be added attr(net, 'n_edges')
#> [1] 12