carve_mst: Carve a Minimal Spanning Tree Out

Description Usage Arguments Details Value Examples

View source: R/tree_routines.R

Description

Given node names, this function retrieves the smallest tree containing at most those nodes.

Usage

1
carve_mst(th, node_names)

Arguments

th

An object of class TreeHarp.

node_names

A character vector of node names. Nodes outside this set will not be returned in the tree. It must include the root node name.

Details

The function starts from each node specified and works it's way up to the root. If a branch contains nodes outside the list, it is shortened.

In the end, the tree that is returned will try to contain all the named nodes, but if that's not possible some will dropped to ensure a tree is returned, not a disconnected graph.

Value

An object of class TreeHarp.

Examples

1
2
3
4
5
ex1 <- quote(x <- f(y, g(5)))
th1 <- TreeHarp(ex1, TRUE)
carve_mst(th1, c("<-", "x", "f", "5")) ## note: 5 is dropped.
carve_mst(th1, c("<-", "x", "f", "y")) 
carve_mst(th1, c("<-", "f", "g")) 

autoharp documentation built on Nov. 13, 2021, 1:06 a.m.

Related to carve_mst in autoharp...