degree: Vertex Degrees in Trees and Networks

View source: R/summary.phylo.R

degreeR Documentation

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 class 'phylo'
degree(x, details = FALSE, ...)
## S3 method for class 'evonet'
degree(x, details = FALSE, ...)

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.

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.

Value

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

Author(s)

Emmanuel Paradis

See Also

checkValidPhylo

Examples

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

ape documentation built on May 29, 2024, 10:50 a.m.