getCommonSubtrees: Get common subtrees of two trees.

View source: R/metrics.R

getCommonSubtreesR Documentation

Get common subtrees of two trees.

Description

Given two spanning trees, the function returns the subtrees of the intersection of these.

Usage

getCommonSubtrees(x, y, n = NULL)

Arguments

x

[matrix]
Edge list of first tree.

y

[matrix]
Edge list of second tree.

n

[integer(1) | NULL]
Number of nodes. Default to ncol(x) + 1.

Value

[list] List of matrizes. Each matrix contains the edges of one connected subtree.

Examples

# assume we have a graph with n = 10 nodes
n.nodes = 10
# we define two trees (matrices with colwise edges)
stree1 = matrix(c(1, 2, 1, 3, 2, 4, 5, 6, 6, 7), byrow = FALSE, nrow = 2)
stree2 = matrix(c(1, 3, 1, 2, 2, 4, 5, 8, 6, 7), byrow = FALSE, nrow = 2)
# ... and compute all common subtrees
subtrees = getCommonSubtrees(stree1, stree2, n = 10)

jakobbossek/mcMST documentation built on March 14, 2023, 4:28 p.m.