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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/operators.R
\name{disjoint_union}
\alias{disjoint_union}
\alias{\%du\%}
\title{Disjoint union of graphs}
\usage{
disjoint_union(...)
x \%du\% y
}
\arguments{
\item{\dots}{Graph objects or lists of graph objects.}
\item{x, y}{Graph objects.}
}
\value{
A new graph object.
}
\description{
The union of two or more graphs are created. The graphs are assumed to have
disjoint vertex sets.
}
\details{
\code{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 \verb{\%du\%} operator.
\code{disjoint_union()} handles graph, vertex and edge attributes. In
particular, it merges vertex and edge attributes using the \code{\link[vctrs:vec_c]{vctrs::vec_c()}}
function. For graphs that lack some vertex/edge attribute, the corresponding
values in the new graph are set to a missing value (\code{NA} for scalar attributes,
\code{NULL} for list attributes). 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 (i.e. a \code{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.
}
\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)
}
\seealso{
Other functions for manipulating graph structure:
\code{\link{+.igraph}()},
\code{\link{add_edges}()},
\code{\link{add_vertices}()},
\code{\link{complementer}()},
\code{\link{compose}()},
\code{\link{connect}()},
\code{\link{contract}()},
\code{\link{delete_edges}()},
\code{\link{delete_vertices}()},
\code{\link{difference}()},
\code{\link{difference.igraph}()},
\code{\link{edge}()},
\code{\link{igraph-minus}},
\code{\link{intersection}()},
\code{\link{intersection.igraph}()},
\code{\link{path}()},
\code{\link{permute}()},
\code{\link{rep.igraph}()},
\code{\link{reverse_edges}()},
\code{\link{simplify}()},
\code{\link{union}()},
\code{\link{union.igraph}()},
\code{\link{vertex}()}
}
\author{
Gabor Csardi \email{csardi.gabor@gmail.com}
}
\concept{functions for manipulating graph structure}
\keyword{graphs}
|