
Last chance! 50% off unlimited learning
Sale ends in
Given two spanning trees, the function returns the subtrees of the intersection of these.
getCommonSubtrees(x, y, n = NULL)
[list
] List of matrizes. Each matrix contains the edges of one
connected subtree.
[matrix
]
Edge list of first tree.
[matrix
]
Edge list of second tree.
[integer(1)
| NULL
]
Number of nodes.
Default to ncol(x) + 1
.
# 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)
Run the code above in your browser using DataLab