graphDeath: Perform a cluster death operation (merge an existing cluster)

View source: R/functions.R

graphDeathR Documentation

Perform a cluster death operation (merge an existing cluster)

Description

graphDeath takes in a spanning forest graph with k disconnected components corresponding to the vector of cluster assignments 'membership' and merges two connected clusters together. It requires the original graph (as generated by constructGraph) to determine what edges in the modified graph are available to be returned in order to connect disconnected components. From the list of edges which connect vertices belonging to different clusters (see edgeBetweenClust), one is uniformly randomly selected and returned to the output graph, reducing the number of clusters by one.

Usage

graphDeath(graph, membership, full_graph)

Arguments

graph

An object of class 'graph' from the igraph package

membership

A vector of integers of length N with k unique integers (1 < k <= N) which map each vertex to a cluster

full_graph

An object of class 'graph' from the igraph package; 'graph' should be a subgraph of full_graph

Value

A list containing two elements:

graph

The input graph with 1 additional active edge

membership

A vector of integers of length N with k - 1 unique integers which map each vertex to a cluster

new_clust_ids

Vertex keys of the vertices belonging to the newly unified cluster

old_clust_ids

Vertex keys of the vertices belonging only to the cluster being merged which has a higher number

References

Luo, Z.T. (*), Sang, H. and Mallick, B.K. (2021), BAST: Bayesian Additive Regression Spanning Trees for Complex Constrained Domain

Luo, Z.T. (*), Sang, H. and Mallick, B.K. (2021), A Bayesian Contiguous Partitioning Method for Learning Clustered Latent Variables, Journal of Machine Learning Research, 22, 1-52.

See Also

constructClusters, graphBirth, graphChange, graphHyper

Examples

set.seed(1)
coords = data.frame(lon = rnorm(50), lat = rnorm(50))
g = constructGraph(coords, 6)
clust_out = constructClusters(g, 8, minclust = 3)
plot(clust_out$spanning_forest,
     layout = as.matrix(coords),
     vertex.color = clust_out$membership,
     edge.arrow.mode = 0)
g_7_clusters = graphDeath(clust_out$spanning_forest,
                          clust_out$membership,
                          g)
plot(g_7_clusters$graph,
     layout = as.matrix(coords),
     vertex.color = g_7_clusters$membership,
     edge.arrow.mode = 0)

rayisaacalan/BASTION documentation built on April 27, 2023, 2:06 p.m.