get_critical_nodes: Extract Critical Nodes from Critical Edge Results

View source: R/get_critical_nodes.R

get_critical_nodesR Documentation

Extract Critical Nodes from Critical Edge Results

Description

Given the output of identify_critical_links, this function identifies the unique nodes involved in the critical edges and summarizes their participation. Each node is reported with the number of critical edges it participates in (its critical degree). If node labels are supplied, they are included in the output.

Usage

get_critical_nodes(result, node_labels = NULL)

Arguments

result

The list returned by identify_critical_links. Must contain a critical_edges component (a data frame with columns node1 and node2, or NULL).

node_labels

An optional character vector of length p (the number of nodes in the network), where node_labels[i] is the label for node i. If NULL (the default), no labels are included.

Value

A data frame with the following columns, ordered by decreasing critical_degree:

node

Integer node index.

label

Character label for the node (only present when node_labels is not NULL).

critical_degree

Number of critical edges incident on this node.

If no critical edges were found (result$critical_edges is NULL or has zero rows), an empty data frame with the same columns is returned.

Examples

# Generate two synthetic populations with different community structure
control <- generate_category_graphs(n_graphs = 15, n_nodes = 10,
  n_communities = 2, base_intra_prob = 0.8, base_inter_prob = 0.2, seed = 1)
patient <- generate_category_graphs(n_graphs = 15, n_nodes = 10,
  n_communities = 2, base_intra_prob = 0.5, base_inter_prob = 0.5, seed = 2)
populations <- list(Control = control, Patient = patient)

# Identify critical edges
result <- identify_critical_links(populations, alpha = 0.05,
  method = "fisher", n_permutations = 200, seed = 42)

# Extract critical nodes (no labels)
get_critical_nodes(result)

# With labels
labels <- paste0("Region_", 1:10)
get_critical_nodes(result, node_labels = labels)

BrainNetTest documentation built on Dec. 3, 2026, 5:08 p.m.