Skip to contents

Compute the Minimum Spanning Tree (MST) from a Distance Matrix

Usage

dismat_mst(mat)

Arguments

mat

A symmetric numeric distance matrix.

Value

A data frame with columns `from`, `to`, and `weight` representing MST edges.

Details

Converts a full square distance matrix into a graph and computes the minimum spanning tree. Returns the MST edges as a long-format data frame.

Examples

dist_mat <- as.matrix(dist(matrix(rnorm(25), ncol = 5)))
mst_edges <- dismat_mst(dist_mat)
#> Error in dismat_mst(dist_mat): could not find function "dismat_mst"
print(mst_edges)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'print': object 'mst_edges' not found