rgraph | R Documentation |
Wrapper of functionality from package igraph
for random generation of
graphs.
rgraph(p, d, dag = FALSE, ordered = TRUE)
p |
Number of vertices of the sampled graph. |
d |
Proportion of edges in the generated graph. |
dag |
Whether the generated graph should be acyclic directed. |
ordered |
When generating an acyclic directed graph, whether the nodes
should follow the ancestral order |
When dag = FALSE
, the graph is sampled from an Erdos-Renyi model.
In the case where dag = TRUE
, the upper triangle of the adjacency matrix of
an Erdos-Renyi model is taken as the adjacency matrix for the acyclic
digraph. This preserves the proportion of edges d
.
The generated graph.
## Random undirected graph with 3 nodes and 50% density of edges rgraph(p = 3, d = 0.5) ## Random directed acyclic graphs # Following the natural ancestral order 1, ..., p dag <- rgraph(p = 6, d = 0.5, dag = TRUE) igraph::topo_sort(dag) # Following a random ancestral order dag <- rgraph(p = 6, d = 0.5, dag = TRUE, ordered = FALSE) igraph::topo_sort(dag)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.