clusterGraph: Remove inter-cluster edges from a graph

View source: R/functions.R

clusterGraphR Documentation

Remove inter-cluster edges from a graph

Description

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).

Usage

clusterGraph(graph, membership)

Arguments

graph

An object of class 'graph' from the igraph package.

membership

A vector of integers of length N (see constructClusters)

Value

An object of class 'graph' from the igraph package, the input graph with inter-cluster edges removed

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.

Examples

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)

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