add_star {DiagrammeR} | R Documentation |
With a graph object of class
dgr_graph
, add a node star to the graph.
add_star(graph, n, type = NULL, label = TRUE, rel = NULL)
graph |
a graph object of class
|
n |
the number of nodes comprising the star. The first node will be the center of the star. |
type |
an optional string that describes the entity type for the nodes to be added. |
label |
either a vector object of length
|
rel |
an optional string for providing a relationship label to all new edges created in the node star. |
a graph object of class dgr_graph
.
# Create a new graph and add 2 stars of varying # numbers of nodes graph <- create_graph() %>% add_star(4, "four_star") %>% add_star(5, "five_star") # Get node information from this graph node_info(graph) #> id type label deg indeg outdeg loops #> 1 1 four_star 1 3 0 3 0 #> 2 2 four_star 2 1 1 0 0 #> 3 3 four_star 3 1 1 0 0 #> 4 4 four_star 4 1 1 0 0 #> 5 5 five_star 1 4 0 4 0 #> 6 6 five_star 2 1 1 0 0 #> 7 7 five_star 3 1 1 0 0 #> 8 8 five_star 4 1 1 0 0 #> 9 9 five_star 5 1 1 0 0