+<html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>Utils · GNNlib.jl</title><meta name="title" content="Utils · GNNlib.jl"/><meta property="og:title" content="Utils · GNNlib.jl"/><meta property="twitter:title" content="Utils · GNNlib.jl"/><meta name="description" content="Documentation for GNNlib.jl."/><meta property="og:description" content="Documentation for GNNlib.jl."/><meta property="twitter:description" content="Documentation for GNNlib.jl."/><script data-outdated-warner src="../../assets/warner.js"></script><link href="https://cdnjs.cloudflare.com/ajax/libs/lato-font/3.0.0/css/lato-font.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/juliamono/0.050/juliamono.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet" type="text/css"/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.8/katex.min.css" rel="stylesheet" type="text/css"/><script>documenterBaseURL="../.."</script><script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" data-main="../../assets/documenter.js"></script><script src="../../search_index.js"></script><script src="../../siteinfo.js"></script><script src="../../../versions.js"></script><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-mocha.css" data-theme-name="catppuccin-mocha"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-macchiato.css" data-theme-name="catppuccin-macchiato"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-frappe.css" data-theme-name="catppuccin-frappe"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/catppuccin-latte.css" data-theme-name="catppuccin-latte"/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/documenter-dark.css" data-theme-name="documenter-dark" data-theme-primary-dark/><link class="docs-theme-link" rel="stylesheet" type="text/css" href="../../assets/themes/documenter-light.css" data-theme-name="documenter-light" data-theme-primary/><script src="../../assets/themeswap.js"></script></head><body><div id="documenter"><nav class="docs-sidebar"><div class="docs-package-name"><span class="docs-autofit"><a href="../../">GNNlib.jl</a></span></div><button class="docs-search-query input is-rounded is-small is-clickable my-2 mx-auto py-1 px-2" id="documenter-search-query">Search docs (Ctrl + /)</button><ul class="docs-menu"><li><a class="tocitem" href="../../">Home</a></li><li><a class="tocitem" href="../../messagepassing/">Message Passing</a></li><li><span class="tocitem">API Reference</span><ul><li><a class="tocitem" href="../messagepassing/">Message Passing</a></li><li class="is-active"><a class="tocitem" href>Utils</a><ul class="internal"><li><a class="tocitem" href="#Index"><span>Index</span></a></li><li><a class="tocitem" href="#Docs"><span>Docs</span></a></li></ul></li></ul></li></ul><div class="docs-version-selector field has-addons"><div class="control"><span class="docs-label button is-static is-size-7">Version</span></div><div class="docs-selector control is-expanded"><div class="select is-fullwidth is-size-7"><select id="documenter-version-selector"></select></div></div></div></nav><div class="docs-main"><header class="docs-navbar"><a class="docs-sidebar-button docs-navbar-link fa-solid fa-bars is-hidden-desktop" id="documenter-sidebar-button" href="#"></a><nav class="breadcrumb"><ul class="is-hidden-mobile"><li><a class="is-disabled">API Reference</a></li><li class="is-active"><a href>Utils</a></li></ul><ul class="is-hidden-tablet"><li class="is-active"><a href>Utils</a></li></ul></nav><div class="docs-right"><a class="docs-navbar-link" href="https://github.com/JuliaGraphs/GraphNeuralNetworks.jl" title="View the repository on GitHub"><span class="docs-icon fa-brands"></span><span class="docs-label is-hidden-touch">GitHub</span></a><a class="docs-navbar-link" href="https://github.com/JuliaGraphs/GraphNeuralNetworks.jl/blob/master/GNNlib/docs/src/api/utils.md" title="Edit source on GitHub"><span class="docs-icon fa-solid"></span></a><a class="docs-settings-button docs-navbar-link fa-solid fa-gear" id="documenter-settings-button" href="#" title="Settings"></a><a class="docs-article-toggle-button fa-solid fa-chevron-up" id="documenter-article-toggle-button" href="javascript:;" title="Collapse all docstrings"></a></div></header><article class="content" id="documenter-page"><h1 id="Utility-Functions"><a class="docs-heading-anchor" href="#Utility-Functions">Utility Functions</a><a id="Utility-Functions-1"></a><a class="docs-heading-anchor-permalink" href="#Utility-Functions" title="Permalink"></a></h1><h2 id="Index"><a class="docs-heading-anchor" href="#Index">Index</a><a id="Index-1"></a><a class="docs-heading-anchor-permalink" href="#Index" title="Permalink"></a></h2><ul><li><a href="#GNNlib.broadcast_edges"><code>GNNlib.broadcast_edges</code></a></li><li><a href="#GNNlib.broadcast_nodes"><code>GNNlib.broadcast_nodes</code></a></li><li><a href="#GNNlib.reduce_edges"><code>GNNlib.reduce_edges</code></a></li><li><a href="#GNNlib.reduce_nodes"><code>GNNlib.reduce_nodes</code></a></li><li><a href="#GNNlib.softmax_edge_neighbors"><code>GNNlib.softmax_edge_neighbors</code></a></li><li><a href="#GNNlib.softmax_edges"><code>GNNlib.softmax_edges</code></a></li><li><a href="#GNNlib.softmax_nodes"><code>GNNlib.softmax_nodes</code></a></li></ul><h2 id="Docs"><a class="docs-heading-anchor" href="#Docs">Docs</a><a id="Docs-1"></a><a class="docs-heading-anchor-permalink" href="#Docs" title="Permalink"></a></h2><h3 id="Graph-wise-operations"><a class="docs-heading-anchor" href="#Graph-wise-operations">Graph-wise operations</a><a id="Graph-wise-operations-1"></a><a class="docs-heading-anchor-permalink" href="#Graph-wise-operations" title="Permalink"></a></h3><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="GNNlib.reduce_nodes" href="#GNNlib.reduce_nodes"><code>GNNlib.reduce_nodes</code></a> — <span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">reduce_nodes(aggr, g, x)</code></pre><p>For a batched graph <code>g</code>, return the graph-wise aggregation of the node features <code>x</code>. The aggregation operator <code>aggr</code> can be <code>+</code>, <code>mean</code>, <code>max</code>, or <code>min</code>. The returned array will have last dimension <code>g.num_graphs</code>.</p><p>See also: <a href="#GNNlib.reduce_edges"><code>reduce_edges</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/CarloLucibello/GraphNeuralNetworks.jl/blob/v0.2.2/src/utils.jl#L3-L11">source</a></section><section><div><pre><code class="language-julia hljs">reduce_nodes(aggr, indicator::AbstractVector, x)</code></pre><p>Return the graph-wise aggregation of the node features <code>x</code> given the graph indicator <code>indicator</code>. The aggregation operator <code>aggr</code> can be <code>+</code>, <code>mean</code>, <code>max</code>, or <code>min</code>.</p><p>See also <a href="https://carlolucibello.github.io/GraphNeuralNetworks.jl/GNNGraphs/api/gnngraph/#GNNGraphs.graph_indicator-Tuple%7BGNNGraph%7D"><code>graph_indicator</code></a>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/CarloLucibello/GraphNeuralNetworks.jl/blob/v0.2.2/src/utils.jl#L18-L25">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="GNNlib.reduce_edges" href="#GNNlib.reduce_edges"><code>GNNlib.reduce_edges</code></a> — <span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">reduce_edges(aggr, g, e)</code></pre><p>For a batched graph <code>g</code>, return the graph-wise aggregation of the edge features <code>e</code>. The aggregation operator <code>aggr</code> can be <code>+</code>, <code>mean</code>, <code>max</code>, or <code>min</code>. The returned array will have last dimension <code>g.num_graphs</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/CarloLucibello/GraphNeuralNetworks.jl/blob/v0.2.2/src/utils.jl#L30-L36">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="GNNlib.softmax_nodes" href="#GNNlib.softmax_nodes"><code>GNNlib.softmax_nodes</code></a> — <span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">softmax_nodes(g, x)</code></pre><p>Graph-wise softmax of the node features <code>x</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/CarloLucibello/GraphNeuralNetworks.jl/blob/v0.2.2/src/utils.jl#L44-L48">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="GNNlib.softmax_edges" href="#GNNlib.softmax_edges"><code>GNNlib.softmax_edges</code></a> — <span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">softmax_edges(g, e)</code></pre><p>Graph-wise softmax of the edge features <code>e</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/CarloLucibello/GraphNeuralNetworks.jl/blob/v0.2.2/src/utils.jl#L59-L63">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="GNNlib.broadcast_nodes" href="#GNNlib.broadcast_nodes"><code>GNNlib.broadcast_nodes</code></a> — <span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">broadcast_nodes(g, x)</code></pre><p>Graph-wise broadcast array <code>x</code> of size <code>(*, g.num_graphs)</code> to size <code>(*, g.num_nodes)</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/CarloLucibello/GraphNeuralNetworks.jl/blob/v0.2.2/src/utils.jl#L99-L104">source</a></section></article><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="GNNlib.broadcast_edges" href="#GNNlib.broadcast_edges"><code>GNNlib.broadcast_edges</code></a> — <span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">broadcast_edges(g, x)</code></pre><p>Graph-wise broadcast array <code>x</code> of size <code>(*, g.num_graphs)</code> to size <code>(*, g.num_edges)</code>.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/CarloLucibello/GraphNeuralNetworks.jl/blob/v0.2.2/src/utils.jl#L111-L116">source</a></section></article><h3 id="Neighborhood-operations"><a class="docs-heading-anchor" href="#Neighborhood-operations">Neighborhood operations</a><a id="Neighborhood-operations-1"></a><a class="docs-heading-anchor-permalink" href="#Neighborhood-operations" title="Permalink"></a></h3><article class="docstring"><header><a class="docstring-article-toggle-button fa-solid fa-chevron-down" href="javascript:;" title="Collapse docstring"></a><a class="docstring-binding" id="GNNlib.softmax_edge_neighbors" href="#GNNlib.softmax_edge_neighbors"><code>GNNlib.softmax_edge_neighbors</code></a> — <span class="docstring-category">Function</span><span class="is-flex-grow-1 docstring-article-toggle-button" title="Collapse docstring"></span></header><section><div><pre><code class="language-julia hljs">softmax_edge_neighbors(g, e)</code></pre><p>Softmax over each node's neighborhood of the edge features <code>e</code>.</p><p class="math-container">\[\mathbf{e}'_{j\to i} = \frac{e^{\mathbf{e}_{j\to i}}}
0 commit comments