graphBirth | R Documentation |
graphBirth
takes in a spanning forest graph with k disconnected components corresponding to
the vector of cluster assignments 'membership' and splits an existing cluster. Optionally, the integer corresponding
to one of the clusters can be specified as the one to split. If it is not specified, a cluster is uniformly selected at random.
In the specified or selected cluster, an edge is uniformly randomly selected and cut, turning the one cluster into two.
graphBirth(graph, membership, clust = NULL)
graph |
An object of class 'graph' from the |
membership |
A vector of integers of length N with k unique integers (k < N) which map each vertex to a cluster |
clust |
(Optional) Integer, the cluster to split. Must be between 1 and k. By default, a cluster will be uniformly randomly selected |
A list containing two elements:
graph |
The input graph with 1 fewer 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 new cluster |
old_clust_ids |
Vertex keys of the vertices from the cluster which was split excluding the ones from |
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
, graphDeath
, graphChange
, graphHyper
set.seed(1234)
coords = data.frame(lon = rnorm(50), lat = rnorm(50))
g = constructGraph(coords, 5)
clust_out = constructClusters(g, 6, minclust = 5)
plot(clust_out$spanning_forest,
layout = as.matrix(coords),
vertex.color = clust_out$membership,
edge.arrow.mode = 0)
g_7_clusters = graphBirth(clust_out$spanning_forest,
clust_out$membership,
4)
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.