Arborescence {rdecision}R Documentation

A rooted directed tree

Description

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

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.

Super classes

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

Methods

Public 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 parent()

Find the parent of a Node.

Usage
Arborescence$parent(v)
Arguments
v

Index node, or a list of index Nodes.

Returns

A list of Nodes of the same length as v, if v is a list, or a scalar Node if v is a single node. NA if v (or an element of v) is the root node.


Method is_parent()

Test whether the given node(s) is (are) parent(s).

Usage
Arborescence$is_parent(v)
Arguments
v

Node to test, or a list of Nodes.

Details

In an arborescence, is_parent() and is_leaf() are mutually exclusive.

Returns

A logical vector of the same length as v, if v is a list, or a logical scalar if v is a single node.


Method is_leaf()

Test whether the given node is a leaf.

Usage
Arborescence$is_leaf(v)
Arguments
v

Node to test, or a list of Nodes.

Details

In an arborescence, is_parent() and is_leaf() are mutually exclusive.

Returns

A logical vector of the same length as v, if v is a list, or a logical scalar is v is a single node.


Method root()

Find the root vertex of the arborescence.

Usage
Arborescence$root()
Returns

The root vertex.


Method is_root()

Is the specified node the root?

Usage
Arborescence$is_root(v)
Arguments
v

Vertex to test, or list of vertexes

Returns

A logical vector if v is a list, or a logical scalar if v is a single node.


Method siblings()

Find the siblings of a vertex in the arborescence.

Usage
Arborescence$siblings(v)
Arguments
v

Vertex to test (only accepts a scalar Node).

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.

Details

In the rdecision implementation, the sibling order is taken to be the lexicographic order of the node labels, if they are unique among siblings, or the node indexes otherwise.

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.

Author(s)

Andrew Sims andrew.sims@newcastle.ac.uk

References

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


[Package rdecision version 1.2.0 Index]