Skip to content

Minimum spanning trees #203

Answered by luukvdmeer
francescmolne asked this question in Q&A
Discussion options

You must be logged in to vote

As of sfnetworks v1.0

To create a spatial minimum spanning tree only from a set of spatial points:

library(sfnetworks)

# Using here the mozart dataset of point locations
mst = as_sfnetwork(mozart, "mst")

To create a spatial minimum spanning tree of an existing network:

library(sfnetworks)
library(tidygraph)

as_sfnetwork(roxel) |>
  activate(edges) |>
  mutate(length = edge_length()) |>
  convert(to_minimum_spanning_tree, weights = length)

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by luukvdmeer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants