% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/structural-properties.R
\name{count_reachable}
\alias{count_reachable}
\title{Count reachable vertices}
\usage{
count_reachable(graph, mode = c("out", "in", "all", "total"))
}
\arguments{
\item{graph}{The input graph.}

\item{mode}{Character constant, defines how edge directions are considered
in directed graphs.
\code{"out"} counts vertices reachable via outgoing edges,
\code{"in"} counts vertices from which the current vertex is reachable via
incoming edges,
\code{"all"} or \code{"total"} ignores edge directions.
This parameter is ignored for undirected graphs.}
}
\value{
An integer vector of length \code{vcount(graph)}.
The i-th element is the number of vertices reachable from vertex i
(including vertex i itself).
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}
}
\details{
Counts the number of vertices reachable from each vertex in the graph.

For each vertex in the graph, this function counts how many vertices
are reachable from it, including the vertex itself.
A vertex is reachable from another if there is a directed path between them.
For undirected graphs, two vertices are reachable from each other if they
are in the same connected component.
}
\section{Related documentation in the C library}{
\href{https://igraph.org/c/html/0.10.17/igraph-Structural.html#igraph_count_reachable}{\code{count_reachable()}}
}

\examples{

# In a directed path graph, the reachability depends on direction
g <- make_graph(~ 1 -+ 2 -+ 3 -+ 4 -+ 5)
count_reachable(g, mode = "out")
count_reachable(g, mode = "in")

# In an undirected graph, reachability is the same in all directions
g2 <- make_graph(~ 1 - 2 - 3 - 4 - 5)
count_reachable(g2, mode = "out")

# A graph with multiple components
g3 <- make_graph(~ 1 - 2 - 3, 4 - 5, 6)
count_reachable(g3, mode = "all")

}
\seealso{
\code{\link[=components]{components()}}, \code{\link[=subcomponent]{subcomponent()}}, \code{\link[=is_connected]{is_connected()}}

Connected components
\code{\link{articulation_points}()},
\code{\link{biconnected_components}()},
\code{\link{component_distribution}()},
\code{\link{decompose}()},
\code{\link{is_biconnected}()}
}
\author{
Gabor Csardi \email{csardi.gabor@gmail.com}
}
\concept{components}
\keyword{graphs}
