Sets the parent node (or block) for a given node. Takes child node's id (string), parent node's id (string), and the level of child node (int).

set_node_parent(sbm, child_id, parent_id, level = 0)

Arguments

sbm

sbm_network object as created by new_sbm_network.

child_id

Id of node for which parent is being added

parent_id

Id of parent node

level

Level of child node. This will almost always stay at default value of 0.

Value

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

See also

Examples

# Create a model with two nodes, one at the block level (1) # Start with bipartite network with 6 nodes net <- dplyr::tribble( ~a_node, ~b_node, "a1" , "b1" , "a1" , "b2" , "a1" , "b3" , "a2" , "b1" , "a3" , "b1" ) %>% new_sbm_network(bipartite_edges = TRUE, edges_from_col = a_node, edges_to_col = b_node) get_state(net)
#> id parent type level #> 1 a1 none a_node 0 #> 2 a2 none a_node 0 #> 3 a3 none a_node 0 #> 4 b1 none b_node 0 #> 5 b2 none b_node 0 #> 6 b3 none b_node 0
# Make a parent node and assign it to a1 net <- set_node_parent(net, child_id = 'a1', parent_id = 'a1_parent') get_state(net)
#> id parent type level #> 1 a1 a1_parent a_node 0 #> 2 a2 none a_node 0 #> 3 a3 none a_node 0 #> 4 b1 none b_node 0 #> 5 b2 none b_node 0 #> 6 b3 none b_node 0 #> 7 a1_parent none a_node 1