File: is_forest.Rd

package info (click to toggle)
r-cran-igraph 2.1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 27,044 kB
  • sloc: ansic: 204,981; cpp: 21,711; fortran: 4,090; yacc: 1,229; lex: 519; sh: 52; makefile: 8
file content (58 lines) | stat: -rw-r--r-- 1,995 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/trees.R
\name{is_forest}
\alias{is_forest}
\title{Decide whether a graph is a forest.}
\usage{
is_forest(graph, mode = c("out", "in", "all", "total"), details = FALSE)
}
\arguments{
\item{graph}{An igraph graph object}

\item{mode}{Whether to consider edge directions in a directed graph.
\sQuote{all} ignores edge directions; \sQuote{out} requires edges to be
oriented outwards from the root, \sQuote{in} requires edges to be oriented
towards the root.}

\item{details}{Whether to return only whether the graph is a tree (\code{FALSE})
or also a possible root (\code{TRUE})}
}
\value{
When \code{details} is \code{FALSE}, a logical value that indicates
whether the graph is a tree. When \code{details} is \code{TRUE}, a named
list with two entries: \item{res}{Logical value that indicates whether the
graph is a tree.} \item{root}{The root vertex of the tree; undefined if
the graph is not a tree.}
}
\description{
\code{is_forest()} decides whether a graph is a forest, and optionally returns a
set of possible root vertices for its components.
}
\details{
An undirected graph is a forest if it has no cycles. In the directed case,
a possible additional requirement is that edges in each tree are oriented
away from the root (out-trees or arborescences) or all edges are oriented
towards the root (in-trees or anti-arborescences). This test can be
controlled using the mode parameter.

By convention, the null graph (i.e. the graph with no vertices) is considered
to be a forest.
}
\examples{

g <- make_tree(3) + make_tree(5,3)
is_forest(g)
is_forest(g, details = TRUE)

}
\seealso{
Other trees: 
\code{\link{is_tree}()},
\code{\link{make_from_prufer}()},
\code{\link{sample_spanning_tree}()},
\code{\link{to_prufer}()}
}
\concept{trees}
\keyword{graphs}
\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_is_forest}{\code{igraph_is_forest()}}.}