Learn R Programming

cograph (version 2.7.2)

cluster_quality: Cluster Quality Metrics

Description

Computes per-cluster and global quality metrics for network partitioning. Supports both binary and weighted networks.

Usage

cluster_quality(x, clusters, weighted = TRUE, directed = TRUE)

cqual(x, clusters, weighted = TRUE, directed = TRUE)

Value

A cluster_quality object (a list) with:

per_cluster

Data frame, one row per cluster, with columns cluster (index), cluster_name, n_nodes, internal_edges (within-cluster weight), cut_edges (boundary-crossing weight), internal_density, avg_internal_degree, expansion, cut_ratio and conductance.

global

List with modularity (Newman-Girvan, computed on the weighted or binarized matrix), coverage (share of total weight that is internal to some cluster) and n_clusters.

See cluster_quality.

Arguments

x

Adjacency matrix (numeric)

clusters

Cluster specification (named list, data frame, or membership vector; see csum)

weighted

Logical; if TRUE (default), use edge weights; if FALSE, binarize the matrix first

directed

Logical; if TRUE (default), treat as directed network

Examples

Run this code
mat <- matrix(runif(100), 10, 10)
diag(mat) <- 0
clusters <- c(1,1,1,2,2,2,3,3,3,3)

q <- cluster_quality(mat, clusters)
q$per_cluster   # Per-cluster metrics
q$global        # Modularity, coverage
mat <- matrix(runif(100), 10, 10)
diag(mat) <- 0
cqual(mat, c(1,1,1,2,2,2,3,3,3,3))

Run the code above in your browser using DataLab