add_gnp_graph {DiagrammeR} | R Documentation |
Add a G(n, p) Erdos-Renyi graph
Description
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.
Usage
add_gnp_graph(
graph,
n,
p,
loops = FALSE,
type = NULL,
label = TRUE,
rel = NULL,
node_aes = NULL,
edge_aes = NULL,
node_data = NULL,
edge_data = NULL,
set_seed = NULL
)
Arguments
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 |
type |
An optional string that describes the entity type for all the nodes to be added. |
label |
A boolean value where setting to |
rel |
An optional string for providing a relationship label to all edges to be added. |
node_aes |
An optional list of named vectors comprising node aesthetic
attributes. The helper function |
edge_aes |
An optional list of named vectors comprising edge aesthetic
attributes. The helper function |
node_data |
An optional list of named vectors comprising node data
attributes. The helper function |
edge_data |
An optional list of named vectors comprising edge data
attributes. The helper function |
set_seed |
Supplying a value sets a random seed of the
|
Value
A graph object of class dgr_graph
.
Examples
# 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 %>% count_nodes()
# Get a count of edges
gnp_graph %>% count_edges()