Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

disjoint_union

Disjoint union of graphs


Description

The union of two or more graphs are created. The graphs are assumed to have disjoint vertex sets.

Usage

disjoint_union(...)

x %du% y

Arguments

...

Graph objects or lists of graph objects.

x, y

Graph objects.

Details

disjoint_union creates a union of two or more disjoint graphs. Thus first the vertices in the second, third, etc. graphs are relabeled to have completely disjoint graphs. Then a simple union is created. This function can also be used via the %du% operator.

graph.disjont.union handles graph, vertex and edge attributes. In particular, it merges vertex and edge attributes using the basic c() function. For graphs that lack some vertex/edge attribute, the corresponding values in the new graph are set to NA. Graph attributes are simply copied to the result. If this would result a name clash, then they are renamed by adding suffixes: _1, _2, etc.

Note that if both graphs have vertex names (ie. a name vertex attribute), then the concatenated vertex names might be non-unique in the result. A warning is given if this happens.

An error is generated if some input graphs are directed and others are undirected.

Value

A new graph object.

Author(s)

Examples

## A star and a ring
g1 <- make_star(10, mode="undirected")
V(g1)$name <- letters[1:10]
g2 <- make_ring(10)
V(g2)$name <- letters[11:20]
print_all(g1 %du% g2)

igraph

Network Analysis and Visualization

v1.2.10
GPL (>= 2)
Authors
See AUTHORS file.
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.