Description Usage Arguments Value Examples

View source: R/combine_graphs.R

Combine two graphs in order to make a new graph.

1 | ```
combine_graphs(x, y)
``` |

`x` |
A |

`y` |
A |

A graph object of class `dgr_graph`

.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ```
# Create a graph with a cycle
# containing 6 nodes
graph_cycle <-
create_graph() %>%
add_cycle(n = 6)
# Create a random graph with
# 8 nodes and 15 edges using the
# `add_gnm_graph()` function
graph_random <-
create_graph() %>%
add_gnm_graph(
n = 8,
m = 15,
set_seed = 23)
# Combine the two graphs in a
# union operation
combined_graph <-
combine_graphs(
graph_cycle,
graph_random)
# Get the number of nodes in
# the combined graph
combined_graph %>% count_nodes()
# The `combine_graphs()`
# function will renumber
# node ID values in graph `y`
# during the union; this ensures
# that node ID values are unique
combined_graph %>% get_node_ids()
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.