Description Usage Arguments Value Examples
View source: R/random_edge_nodes.R
Return the nodes of an edge in the graph gr
selected at
random. Edges from other nodes can be ignored by passing their index(es) to
ignore_nodes_connected_to
. This is used in swapping edges by passing
the nodes for the first edge to be ignored in the selection of the second
edge.
1 | random_edge_nodes(gr, ignore_nodes_connected_to = c())
|
gr |
tidygraph graph object; must have the node attribute |
ignore_nodes_connected_to |
a vector of indices for the nodes whose edges to ignore |
a vector of two indices for the nodes of the edge selected; if no
edge was able to be selected, then integer(0)
is returned
1 2 3 4 | set.seed(0)
gr <- tidygraph::create_ring(5)
gr <- tidygraph::mutate(gr, .idx = 1:dplyr::n())
random_edge_nodes(gr)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.