Skip to main content

attention_aggregate

Function attention_aggregate 

Source
pub fn attention_aggregate(
    graph: &Graph,
    signal: &[f64],
    attention: &[f64],
) -> IgraphResult<Vec<f64>>
Expand description

Aggregate a signal with per-edge attention weights.

For each vertex v, computes agg(v) = Σ_{u∈N(v)} softmax(attn(v,u)) · signal(u) where softmax normalizes attn scores across N(v).

§Parameters

  • graph — Undirected graph.
  • signal — Input signal of length vcount.
  • attention — Raw attention scores, one per edge. Length must equal ecount. For edge (u,v), the score is used in both directions.

§Examples

use rust_igraph::{Graph, attention_aggregate};

let g = Graph::from_edges(&[(0,1),(0,2)], false, Some(3)).unwrap();
let signal = vec![0.0, 1.0, 2.0];
// Equal attention → equivalent to mean
let agg = attention_aggregate(&g, &signal, &[0.0, 0.0]).unwrap();
assert!((agg[0] - 1.5).abs() < 1e-10); // mean(1, 2)