group_spatial | R Documentation |
These functions forms a spatial extension to the
grouping
functions in tidygraph,
allowing to detect communities with spatial clustering algorithms.
group_spatial_dbscan(epsilon, min_pts = 1, use_network_distance = TRUE, ...)
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 |
... |
Additional arguments passed on to the clustering algorithm. |
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.
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.
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.
library(tidygraph, quietly = TRUE)
play_geometric(10, 0.5) |>
activate(nodes) |>
mutate(group = group_spatial_dbscan(0.25))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.