Skip to main content

structural_node_features

Function structural_node_features 

Source
pub fn structural_node_features(adj: &[Vec<usize>]) -> Vec<Vec<f64>>
Expand description

Compute structural node features from an adjacency list.

Returns per-node feature vectors: [degree, clustering_coefficient, avg_neighbor_degree].

These features capture local graph topology and can be used with sliced_wasserstein_graph_kernel for graphs without explicit node attributes.

§Arguments

  • adj - Adjacency list (undirected; adj[i] lists neighbors of node i)

§Example

use graphops::structural_node_features;

// Triangle: every node has degree 2, clustering coeff 1.0
let adj = vec![vec![1, 2], vec![0, 2], vec![0, 1]];
let features = structural_node_features(&adj);
assert_eq!(features.len(), 3);
assert!((features[0][0] - 2.0).abs() < 1e-10); // degree
assert!((features[0][1] - 1.0).abs() < 1e-10); // clustering