Skip to content

Commit e90e515

Browse files
committed
feat: Reduce nodes over heterogeneous graphs
1 parent 1d0edf8 commit e90e515

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

GNNlib/src/utils.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ function reduce_nodes(aggr, indicator::AbstractVector, x)
2727
return NNlib.scatter(aggr, x, indicator)
2828
end
2929

30+
"""
31+
reduce_nodes(aggr, node_type, g, x)
32+
33+
Return the graph-wise aggregation of the node features `x` on type `node_type`
34+
given a heterogeneous graph `g`. The aggregation operator `aggr` can be `+`,
35+
`mean`, `max`, or `min`.
36+
"""
37+
function reduce_nodes(aggr, node_type, g::GNNHeteroGraph, x)
38+
return NNlib.scatter(aggr, x[node_type], graph_indicator(g, node_type))
39+
end
40+
3041
"""
3142
reduce_edges(aggr, g, e)
3243

0 commit comments

Comments
 (0)