group_spatial: Group nodes based on spatial distance

group_spatialR Documentation

Group nodes based on spatial distance

Description

These functions forms a spatial extension to the grouping functions in tidygraph, allowing to detect communities with spatial clustering algorithms.

Usage

group_spatial_dbscan(epsilon, min_pts = 1, use_network_distance = TRUE, ...)

Arguments

epsilon

The value of the epsilon parameter for the DBSCAN clustering algorithm, defining the radius of the neighborhood of a node.

min_pts

The value of the minPts parameter for the DBSCAN clustering algorithm, defining the minimum number of points in the neighborhood to be considered a core point.

use_network_distance

Should the distance between nodes be computed as the distance over the network (using st_network_distance? Defaults to TRUE. If set to FALSE, the straight-line distance (using st_distance) is computed instead.

...

Additional arguments passed on to the clustering algorithm.

Details

Just as with all grouping functions in tidygraph, spatial grouping functions are meant to be called inside tidygraph verbs such as mutate or filter, where the network that is currently being worked on is known and thus not needed as an argument to the function. If you want to use an algorithm outside of the tidygraph framework you can use with_graph to set the context temporarily while the algorithm is being evaluated.

Value

A numeric vector with the membership for each node in the network. The enumeration happens in order based on group size progressing from the largest to the smallest group.

Functions

  • group_spatial_dbscan(): Uses density-based spatial clustering as implemented in the dbscan function of the dbscan package. This requires the dbscan package to be installed. Each node marked as noise will form its own cluster.

Examples

library(tidygraph, quietly = TRUE)

play_geometric(10, 0.5) |>
  activate(nodes) |>
  mutate(group = group_spatial_dbscan(0.25))


luukvdmeer/sfnetworks documentation built on Nov. 21, 2024, 4:54 a.m.