clusterGraph | R Documentation |
clusterGraph
takes in a graph and the membership vector mapping each vertex to
a certain cluster and returns the input graph with any edges that connect vertices belonging
to distinct clusters removed (see edgeBetweenClust
).
clusterGraph(graph, membership)
graph |
An object of class 'graph' from the |
membership |
A vector of integers of length N (see |
An object of class 'graph' from the igraph
package, the input graph with inter-cluster edges removed
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.
set.seed(1)
coords = data.frame(lon = rnorm(50), lat = rnorm(50))
g = constructGraph(coords, 4)
clust_membership = constructClusters(g, 5, minclust = 3)$membership
clust_g = clusterGraph(g, clust_membership)
plot(clust_g, layout = as.matrix(coords), vertex.color = clust_membership, edge.arrow.mode = 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.