Learn R Programming

ape (version 5.8)

degree: Vertex Degrees in Trees and Networks

Description

degree is a generic function to calculate the degree of all nodes in a tree or in a network.

Usage

degree(x, ...)
# S3 method for phylo
degree(x, details = FALSE, ...)
# S3 method for evonet
degree(x, details = FALSE, ...)

Value

a data frame if details = FALSE, or a vector of integers otherwise.

Arguments

x

an object (tree, network, ...).

details

whether to return the degree of each node in the tree, or a summary table (the default).

...

arguments passed to methods.

Author

Emmanuel Paradis

Details

The degree of a node (or vertex) in a network is defined by the number of branches (or edges) that connect to this node. In a phylogenetic tree, the tips (or terminal nodes) are of degree one, and the (internal) nodes are of degree two or more.

There are currently two methods for the classes "phylo" and "evonet". The default of these functions is to return a summary table with the degrees observed in the tree or network in the first column, and the number of nodes in the second column. If details = TRUE, a vector giving the degree of each node (as numbered in the edge matrix) is returned.

The validity of the object is not checked, so degree can be used to check problems with badly conformed trees.

See Also

checkValidPhylo

Examples

Run this code
data(bird.orders)
degree(bird.orders)
degree(bird.orders, details = TRUE)

data(bird.families)
degree(bird.families)

degree(rtree(10)) # 10, 1, 8
degree(rtree(10, rooted = FALSE)) # 10, 0, 8
degree(stree(10)) # 10 + 1 node of degree 10

Run the code above in your browser using DataLab