is_tree | R Documentation |
is_tree()
decides whether a graph is a tree, and optionally returns a
possible root vertex if the graph is a tree.
is_tree(graph, mode = c("out", "in", "all", "total"), details = FALSE)
graph |
An igraph graph object |
mode |
Whether to consider edge directions in a directed graph. ‘all’ ignores edge directions; ‘out’ requires edges to be oriented outwards from the root, ‘in’ requires edges to be oriented towards the root. |
details |
Whether to return only whether the graph is a tree ( |
An undirected graph is a tree if it is connected and has no cycles. In the directed case, a possible additional requirement is that all edges are oriented away from a root (out-tree or arborescence) or all edges are oriented towards a root (in-tree or anti-arborescence). This test can be controlled using the mode parameter.
By convention, the null graph (i.e. the graph with no vertices) is considered not to be a tree.
When details
is FALSE
, a logical value that indicates
whether the graph is a tree. When details
is TRUE
, a named
list with two entries:
res |
Logical value that indicates whether the graph is a tree. |
root |
The root vertex of the tree; undefined if the graph is not a tree. |
Other trees:
is_forest()
,
make_from_prufer()
,
sample_spanning_tree()
,
to_prufer()
g <- make_tree(7, 2)
is_tree(g)
is_tree(g, details = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.