% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/topology.R
\name{transitive_closure}
\alias{transitive_closure}
\title{Transitive closure of a graph}
\usage{
transitive_closure(graph)
}
\arguments{
\item{graph}{The input graph.
It can be directed or undirected.}
}
\value{
A new graph object representing the transitive closure.
The returned graph will have the same directedness as the input.
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}

Computes the transitive closure of a graph.
The resulting graph will have an edge from vertex \eqn{i} to vertex \eqn{j}
if \eqn{j} is reachable from \eqn{i} in the original graph.

The transitive closure of a graph is a new graph where there is an edge
between any two vertices if there is a path between them in the original
graph.
For directed graphs, an edge from \eqn{i} to \eqn{j} is added if there is
a directed path from \eqn{i} to \eqn{j}.
For undirected graphs, this is equivalent to connecting all vertices that
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_transitive_closure}{\code{transitive_closure()}}
}

\examples{

# Directed graph
g <- make_graph(c(1, 2, 2, 3, 3, 4))
tc <- transitive_closure(g)
# The closure has edges 1->2, 1->3, 1->4, 2->3, 2->4, 3->4
print_all(tc)

# Undirected graph - connects all vertices in same component
g2 <- make_graph(c(1, 2, 3, 4), directed = FALSE)
tc2 <- transitive_closure(g2)
# Full graph on vertices 1, 2 and full graph on vertices 3, 4
print_all(tc2)
}
\seealso{
\code{\link[=distances]{distances()}}, \code{\link[=are_adjacent]{are_adjacent()}}

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{disjoint_union}()},
\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{
Fabio Zanini \email{fabio.zanini@unsw.edu.au}
}
\concept{functions for manipulating graph structure}
\keyword{graphs}
