add_gnp_graph {DiagrammeR} | R Documentation |
To an existing graph object, add a graph built according to the Erdos-Renyi G(n, p) model, which uses a constant probability when creating edges.
add_gnp_graph(graph, n, p, loops = FALSE)
graph |
a graph object of class
|
n |
the number of nodes comprising the generated graph. |
p |
the probability of creating an edge between two arbitrary nodes. |
loops |
a logical value (default is
|
# Create an undirected GNP # graph with 100 nodes using # a probability value of 0.05 gnp_graph <- create_graph( directed = FALSE) %>% add_gnp_graph( n = 100, p = 0.05) # Get a count of nodes gnp_graph %>% node_count() #> [1] 100 # Get a count of edges gnp_graph %>% edge_count() #> [1] 216