Skip to main content

sparse_message_passing

Function sparse_message_passing 

Source
pub fn sparse_message_passing(
    adj_row_offsets: &[usize],
    adj_col_indices: &[usize],
    node_features: &[f64],
    feature_dim: usize,
    config: &GnnSparseConfig,
) -> Result<Vec<f64>, SparseError>
Expand description

Sparse message passing over an adjacency matrix in CSR form.

For each node i, aggregates features from its neighbors using the adjacency structure:

output[i, :] = aggregate_{j in neighbors(i)} features[j, :]

When config.normalize is true, the aggregated result is divided by the degree of node i.

§Arguments

  • adj_row_offsets – CSR row pointer array (length num_nodes + 1).
  • adj_col_indices – CSR column indices (length num_edges).
  • node_features – Dense feature matrix stored row-major (num_nodes x feature_dim).
  • feature_dim – Number of features per node.
  • config – GNN configuration (aggregation op, normalization, etc.).

§Errors

Returns SparseError::DimensionMismatch on inconsistent sizes.