graphHyper | R Documentation |
graphHyper
resamples the spanning trees which together partition the full_graph
(as generated by
constructGraph
) into the clusters specified by membership
. It does this by first resampling every
edge weight from the full graph, with edges connecting vertices currently assigned to different clusters being drawn from
a uniform (0.5, 1) distribution (weighted more heavily), and edges connecting vertices currently assigned to the same
cluster being drawn from a uniform (0, 0.5) distribution (weighted less heavily). Then, the minimum spanning tree across the
entire graph is recalculated using these new weights. By removing the inter-cluster edges from this new MST (see
clusterGraph
), the resultant graph has the same vertex membership, but the individual trees which make up
the spanning forest likely have a different set of edges.
graphHyper(full_graph, membership)
full_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 |
A list containing two elements:
graph |
The input graph with each cluster having a new minimum spanning tree based on resampled edge weights |
membership |
A vector of integers of length N with k unique integers which map each vertex to a cluster |
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
, graphBirth
set.seed(1)
coords = data.frame(lon = rnorm(100), lat = rnorm(100))
g = constructGraph(coords, 5)
clust_out = constructClusters(g, 8, minclust = 6)
plot(clust_out$spanning_forest,
layout = as.matrix(coords),
vertex.color = clust_out$membership,
edge.arrow.mode = 0)
g_resample = graphHyper(g, clust_out$membership)
plot(g_resample$graph,
layout = as.matrix(coords),
vertex.color = g_resample$membership,
edge.arrow.mode = 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.