\HeaderA{decompose.graph}{Decompose a graph into components}{decompose.graph}
\keyword{graphs}{decompose.graph}
\begin{Description}\relax
Creates a separate graph for each component of a graph.
\end{Description}
\begin{Usage}
\begin{verbatim}
decompose.graph(graph, mode = c("weak", "strong"),
       max.comps = NA, min.vertices = 0) 
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{graph}] The original graph.
\item[\code{mode}] Character constant giving the type of the components,
wither \code{weak} for weakly connected components or \code{strong}
for strongly connected components.
\item[\code{max.comps}] The maximum number of components to return. The first
\code{max.comps} components will be returned (which hold at least
\code{min.vertices} vertices, see the next parameter), the others
will be ignored. Supply \code{NA} here if you don't want to limit
the number of components.
\item[\code{min.vertices}] The minimum number of vertices a component should
contain in order to place it in the result list. Eg. supply 2
here to ignore isolate vertices.
\end{ldescription}
\end{Arguments}
\begin{Value}
A list of graph objects.
\end{Value}
\begin{Author}\relax
Gabor Csardi \email{csardi@rmki.kfki.hu}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{is.connected}{is.connected}} to decide whether a graph is
connected, \code{\LinkA{clusters}{clusters}} to calculate the connected
components of a graph.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
# the diameter of each component in a random graph
g <- erdos.renyi.game(1000, 1/1000)
comps <- decompose.graph(g, min.vertices=2)
sapply(comps, diameter)
\end{ExampleCode}
\end{Examples}

