\HeaderA{components}{In- or out- component of a vertex}{components}
\aliasA{subcomponent}{components}{subcomponent}
\keyword{graphs}{components}
\begin{Description}\relax
Finds all vertices reachable from a given vertex, or the
opposite: all vertices from which a given vertex is reachable via a
directed path.
\end{Description}
\begin{Usage}
\begin{verbatim}
subcomponent(graph, v, mode = c("all", "out", "in"))
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{graph}] The graph to analyze.
\item[\code{v}] The vertex to start the search from.
\item[\code{mode}] Character string, either \dQuote{in}, \dQuote{out} or
\dQuote{all}. If \dQuote{in} all vertices from which \code{v} is
reachable are listed. If \dQuote{out} all vertices reachable from
\code{v} are returned. If \dQuote{all} returns the union of
these. It is ignored for undirected graphs.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
A breadh-first search is conducted starting from vertex
\code{v}.
\end{Details}
\begin{Value}
Numeric vector, the ids of the vertices in the same component as
\code{v}.
\end{Value}
\begin{Author}\relax
Gabor Csardi \email{csardi@rmki.kfki.hu}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{clusters}{clusters}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
g <- erdos.renyi.game(100, 1/200)
subcomponent(g, 1, "in")
subcomponent(g, 1, "out")
subcomponent(g, 1, "all")
\end{ExampleCode}
\end{Examples}

