\HeaderA{layout.merge}{Merging graph layouts}{layout.merge}
\aliasA{piecewise.layout}{layout.merge}{piecewise.layout}
\keyword{graphs}{layout.merge}
\begin{Description}\relax
Place several graphs on the same layout
\end{Description}
\begin{Usage}
\begin{verbatim}
layout.merge(graphs, layouts, method = "dla",
       verbose = igraph.par("verbose"))
piecewise.layout(graph, layout=layout.kamada.kawai, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{graphs}] A list of graph objects.
\item[\code{layouts}] A list of two-column matrices.
\item[\code{method}] Character constant giving the method to use. Right now
only \code{dla} is implemented.
\item[\code{verbose}] Logical constant, whether to show a progress bar while
doing the calculation.
\item[\code{graph}] The input graph.
\item[\code{layout}] A function object, the layout function to use.
\item[\code{...}] Additional arguments to pass to the \code{layout} layout
function.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{layout.merge} takes a list of graphs and a list of coordinates and
places the graphs in a common layout. The method to use is chosen via
the \code{method} parameter, although right now only the \code{dla}
method is implemented.

The \code{dla} method covers the graph with circles.
Then it sorts the graphs based on the number of vertices
first and places the largest graph at the center of the layout. Then
the other graphs are placed in decreasing order via a DLA (diffision
limited aggregation) algorithm: the graph is placed randomly on a
circle far away from the center and a random walk is conducted until
the graph walks into the larger graphs already placed or walks too far
from the center of the layout.

The \code{piecewise.layout} function disassembles the graph first into
maximal connected components and calls the supplied \code{layout}
function for each component separately. Finally it merges the layouts
via calling \code{layout.merge}.
\end{Details}
\begin{Value}
A matrix with two columns and as many lines as the total number of
vertices in the graphs.
\end{Value}
\begin{Author}\relax
Gabor Csardi \email{csardi@rmki.kfki.hu}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{plot.igraph}{plot.igraph}}, \code{\LinkA{tkplot}{tkplot}},
\code{\LinkA{layout}{layout}}, \code{\LinkA{graph.disjoint.union}{graph.disjoint.union}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
# create 20 scale-free graphs and place them in a common layout
graphs <- lapply(sample(5:20, 20, replace=TRUE),
          barabasi.game, directed=FALSE)
layouts <- lapply(graphs, layout.kamada.kawai)
lay <- layout.merge(graphs, layouts)
g <- graph.disjoint.union(graphs)
## Not run: plot(g, layout=lay, vertex.size=3, labels=NA, edge.color="black")
\end{ExampleCode}
\end{Examples}

