# MSTDist_FromMat: Calculates the minimum spanning tree distance, in kilometers,... In GeoRange: Calculating Geographic Range from Occurrence Data

## Description

Calculates the minimum spanning tree distance, in kilometers, using Prim's Algorithm [1] and a previously calculated pairwsie distance matrix

## Usage

 `1` ```MSTDist_FromMat(longs, lats, DistMat) ```

## Arguments

 `longs` - Longitudinal occurrences in decimal degrees `lats` - Latitudinal occurrences in decimal degrees `DistMat` - Pairwsie distance matrix of coordinates, from the PWMatrix() function

## Details

Uses Prim's algorithm for finding the minimum spanning tree

## Value

Returns the minimum spanning tree distance in kilometers, the pairwise distance matrix of occurrences, the order points were connected in, and a 2-column array of coordinates

## References

[1] Prim, R.C. 1957. Shortest Connection Networks and Some Generalizations. The Bell System Technical Journal 36:1389-1401.

## Examples

 ```1 2``` ```MSTCalc<-MSTDist(longs=c(22,44,-12,67),lats=c(-77,56,22,56)) MSTDist_FromMat(MSTCalc\$Longitude,MSTCalc\$Latitude,MSTCalc\$MST_DistMat) ```

### Example output

```Warning messages:
1: In min(c(NA_real_, NA_real_, NA_real_, NA_real_), na.rm = TRUE) :
no non-missing arguments to min; returning Inf
2: In min(c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,  :
no non-missing arguments to min; returning Inf
\$MST_km
[1] 18552.83

\$MST_DistMat
X1       X2        X3        X4
1 NA 11216.01  5908.434  7329.294
2 NA       NA 14839.481 15089.651
3 NA       NA        NA  1428.389
4 NA       NA        NA        NA

\$MST_pt_connects
[1] 2 1 1 3 3 4

\$Longitude
[1] -12  22  44  67

\$Latitude
[1]  22 -77  56  56

Warning messages:
1: In min(c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,  :
no non-missing arguments to min; returning Inf
2: In min(c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,  :
no non-missing arguments to min; returning Inf
```

GeoRange documentation built on May 1, 2019, 8:03 p.m.