graphDeath | R Documentation |
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.
graphDeath(graph, membership, full_graph)
graph |
An object of class 'graph' from the |
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 |
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 |
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.
constructClusters
, graphBirth
, graphChange
, graphHyper
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.