Learn R Programming

rdecision (version 1.1.2)

Arborescence: A rooted directed tree

Description

An R6 class representing an arborescence (a rooted directed tree).

Arguments

Author

Andrew Sims andrew.sims@newcastle.ac.uk

Super classes

rdecision::Graph -> rdecision::Digraph -> Arborescence

Methods

Inherited methods


Method new()

Create a new Arborescence object from sets of nodes and edges.

Usage

Arborescence$new(V, A)

Arguments

V

A list of Nodes.

A

A list of Arrows.

Returns

An Arborescence object.


Method is_parent()

Test whether the given node is a parent (has child nodes).

Usage

Arborescence$is_parent(v)

Arguments

v

Node to test

Returns

TRUE if v has one or more child nodes, FALSE otherwise.


Method is_leaf()

Test whether the given node is a leaf. In an arborescence, is_parent() and is_leaf() are mutually exclusive.

Usage

Arborescence$is_leaf(v)

Arguments

v

Vertex to test.

Returns

TRUE if v has no child nodes, FALSE otherwise.


Method root()

Find the root vertex of the arborescence.

Usage

Arborescence$root()

Returns

The root vertex.


Method siblings()

Find the siblings of a vertex in the arborescence.

Usage

Arborescence$siblings(v)

Arguments

v

Vertex to test.

Returns

A (possibly empty) list of siblings.


Method root_to_leaf_paths()

Find all directed paths from the root of the tree to the leaves.

Usage

Arborescence$root_to_leaf_paths()

Returns

A list of ordered node lists.


Method postree()

Implements function POSITIONTREE (Walker, 1989) to determine the coordinates for each node in an arborescence.

Usage

Arborescence$postree(
  SiblingSeparation = 4,
  SubtreeSeparation = 4,
  LevelSeparation = 1,
  RootOrientation = "SOUTH",
  MaxDepth = Inf
)

Arguments

SiblingSeparation

Distance in arbitrary units for the distance between siblings.

SubtreeSeparation

Distance in arbitrary units for the distance between neighbouring subtrees.

LevelSeparation

Distance in arbitrary units for the separation between adjacent levels.

RootOrientation

Must be one of "NORTH", "SOUTH", "EAST", "WEST". Defined as per Walker (1989), but noting that Walker assumed that y increased down the page. Thus the meaning of NORTH and SOUTH are opposite to his, with the default (SOUTH) having the child nodes at positive y value and root at zero, as per his example (figure 12).

MaxDepth

The maximum depth (number of levels) to be drawn; if the tree exceeds this, an error will be raised.

Returns

A data frame with one row per node and three columns (n, x and y) where n gives the node index given by the Graph::vertex_index() function.


Method clone()

The objects of this class are cloneable with this method.

Usage

Arborescence$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Details

Class to encapsulate a directed rooted tree specialization of a digraph. An arborescence is a directed tree with exactly one root and unique directed paths from the root. Inherits from class Digraph.

References

Walker, John Q II. A A node-positioning algorithm for general trees. University of North Carolina Technical Report TR 89-034, 1989.