| add_smallworld_graph {DiagrammeR} | R Documentation |
To an existing graph object, add a graph built according to the Watts-Strogatz small-world model, which uses a lattice along with a rewiring probability to randomly modify edge definitions.
add_smallworld_graph(graph, dimension, size, neighborhood, p, loops = FALSE, multiple = FALSE, type = NULL, label = TRUE, rel = NULL, node_aes = NULL, edge_aes = NULL, node_data = NULL, edge_data = NULL, set_seed = NULL)
graph |
a graph object of class
|
dimension |
the dimension of the starting lattice. |
size |
the size of the lattice across each dimension. |
neighborhood |
the neighborhood where the lattice nodes are to be connected. |
p |
the rewiring probability. |
loops |
a logical value (default
is |
multiple |
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
|
# Create an undirected smallworld
# graph with 100 nodes using
# a probability value of 0.05
smallworld_graph <-
create_graph(
directed = FALSE) %>%
add_smallworld_graph(
dimension = 1,
size = 50,
neighborhood = 1,
p = 0.05,
set_seed = 23)
# Get a count of nodes
smallworld_graph %>%
count_nodes()
# Get a count of edges
smallworld_graph %>%
count_edges()