graphHyper: Generate new spanning trees for each cluster

View source: R/functions.R

graphHyperR Documentation

Generate new spanning trees for each cluster

Description

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.

Usage

graphHyper(full_graph, membership)

Arguments

full_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

Value

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

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, graphDeath, graphChange, graphBirth

Examples

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)

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