| 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
rdecision::Graph$degree()rdecision::Graph$edge_along()rdecision::Graph$edge_at()rdecision::Graph$edge_index()rdecision::Graph$edge_label()rdecision::Graph$edges()rdecision::Graph$graph_adjacency_matrix()rdecision::Graph$has_edge()rdecision::Graph$has_vertex()rdecision::Graph$is_simple()rdecision::Graph$neighbours()rdecision::Graph$order()rdecision::Graph$size()rdecision::Graph$vertex_along()rdecision::Graph$vertex_at()rdecision::Graph$vertex_index()rdecision::Graph$vertex_label()rdecision::Graph$vertexes()rdecision::Digraph$arrow_source()rdecision::Digraph$arrow_target()rdecision::Digraph$as_DOT()rdecision::Digraph$digraph_adjacency_matrix()rdecision::Digraph$digraph_incidence_matrix()rdecision::Digraph$direct_predecessors()rdecision::Digraph$direct_successors()rdecision::Digraph$is_acyclic()rdecision::Digraph$is_arborescence()rdecision::Digraph$is_connected()rdecision::Digraph$is_polytree()rdecision::Digraph$is_tree()rdecision::Digraph$is_weakly_connected()rdecision::Digraph$paths()rdecision::Digraph$topological_sort()rdecision::Digraph$walk()
Method new()
Create a new Arborescence object from sets of nodes
and edges.
Usage
Arborescence$new(V, A)
Arguments
VA list of Nodes.
AA list of Arrows.
Returns
An Arborescence object.
Method parent()
Find the parent of a Node.
Usage
Arborescence$parent(v)
Arguments
vIndex 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
vNode 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
vNode 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
vVertex 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
vVertex 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
SiblingSeparationDistance in arbitrary units for the distance between siblings.
SubtreeSeparationDistance in arbitrary units for the distance between neighbouring subtrees.
LevelSeparationDistance in arbitrary units for the separation between adjacent levels.
RootOrientationMust 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).
MaxDepthThe 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
deepWhether 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.