voronoi_cells: Voronoi partitioning of a graph

voronoi_cellsR Documentation

Voronoi partitioning of a graph

Description

[Experimental]

This function partitions the vertices of a graph based on a set of generator vertices. Each vertex is assigned to the generator vertex from (or to) which it is closest.

groups() may be used on the output of this function.

Usage

voronoi_cells(
  graph,
  generators,
  ...,
  weights = NULL,
  mode = c("out", "in", "all", "total"),
  tiebreaker = c("random", "first", "last")
)

Arguments

graph

The graph to partition into Voronoi cells.

generators

The generator vertices of the Voronoi cells.

...

These dots are for future extensions and must be empty.

weights

Possibly a numeric vector giving edge weights. If this is NULL and the graph has a weight edge attribute, then the attribute is used. If this is NA then no weights are used (even if the graph has a weight attribute). In a weighted graph, the length of a path is the sum of the weights of its constituent edges.

mode

Character string. In directed graphs, whether to compute distances from generator vertices to other vertices ("out"), to generator vertices from other vertices ("in"), or ignore edge directions entirely ("all"). Ignored in undirected graphs.

tiebreaker

Character string that specifies what to do when a vertex is at the same distance from multiple generators. "random" assigns a minimal-distance generator randomly, "first" takes the first one, and "last" takes the last one.

Value

A named list with two components:

membership

numeric vector giving the cluster id to which each vertex belongs.

distances

numeric vector giving the distance of each vertex from its generator

Related documentation in the C library

igraph_voronoi().

See Also

distances()

Community detection as_membership(), cluster_edge_betweenness(), cluster_fast_greedy(), cluster_fluid_communities(), cluster_infomap(), cluster_label_prop(), cluster_leading_eigen(), cluster_leiden(), cluster_louvain(), cluster_optimal(), cluster_spinglass(), cluster_walktrap(), compare(), groups(), make_clusters(), membership(), modularity.igraph(), plot_dendrogram(), split_join_distance()

Examples


g <- make_lattice(c(10,10))
clu <- voronoi_cells(g, c(25, 43, 67))
groups(clu)
plot(g, vertex.color=clu$membership)


igraph documentation built on Oct. 20, 2024, 1:06 a.m.