Skip to main content

symmetric_normalize

Function symmetric_normalize 

Source
pub fn symmetric_normalize(
    adj_row_offsets: &[usize],
    adj_col_indices: &[usize],
    adj_values: &[f64],
    degrees: &[f64],
) -> (Vec<usize>, Vec<usize>, Vec<f64>)
Expand description

Symmetric normalization of an adjacency matrix: D^{-1/2} A D^{-1/2}.

Given a CSR adjacency matrix with values, returns a new CSR matrix with normalized values:

A_hat[i][j] = A[i][j] / sqrt(deg[i] * deg[j])

This is the standard normalization used in GCN (Kipf & Welling, 2017).

§Arguments

  • adj_row_offsets – CSR row pointer.
  • adj_col_indices – CSR column indices.
  • adj_values – CSR values.
  • degrees – Degree of each node (precomputed via compute_degree_matrix).

§Returns

A tuple (row_offsets, col_indices, values) for the normalized CSR matrix. The sparsity pattern is unchanged; only values are modified.