Learn R Programming

Datasmith (version 1.0-1)

mst: Compute Minimum Spanning Tree

Description

mst Compute a minimum spanning tree using Prim's algorithm

Usage

mst(D)

Arguments

D
A distance matrix

Value

MST a data frame object of 3 columns containing the parent nodes, child nodes, and corresponding weight of the MST edge

Examples

Run this code

X <- runif(10,0,1)
Y <- runif(10,0,1)
D <- dist(cbind(X,Y))

mst(as.matrix(D))

Run the code above in your browser using DataLab