Positional encodings (PE) for graphs are essential in constructing powerful and expressive graph neural networks and graph transformers as they effectively capture relative spatial relations between nodes. While PEs for undirected graphs have been extensively studied, those for directed graphs remain largely unexplored, despite the fundamental role of directed graphs in representing entities with strong logical dependencies, such as those in program analysis and circuit designs. This work studies the design of PEs for directed graphs that are expressive to represent desired directed spatial relations. We first propose walk profile, a generalization of walk counting sequence to directed graphs. We identify limitations in existing PE methods, including symmetrized Laplacian PE, Singular Value Decomposition PE, and Magnetic Laplacian PE, in their ability to express walk profiles. To address these limitations, we propose the Multi-q Magnetic Laplacian PE, which extends Magnetic Laplacian PE with multiple potential factors. This simple variant turns out to be capable of provably expressing walk profiles. Furthermore, we generalize previous basis-invariant and stable networks to handle complex-domain PEs decomposed from Magnetic Laplacians. Our numerical experiments demonstrate the effectiveness of Multi-q Magnetic Laplacian PE with a stable neural architecture, outperforming previous PE methods (with stable networks) on predicting directed distances/walk profiles, sorting network satisfiability, and on general circuit benchmarks. Our code is available at https://github.com/Graph-COM/Multi-q-Maglap.
翻译:图位置编码(PE)对于构建强大且表达能力强的图神经网络和图Transformer至关重要,因为它们能有效捕捉节点间的相对空间关系。尽管无向图的位置编码已得到广泛研究,但有向图的位置编码在很大程度上仍未得到探索,尽管有向图在表示具有强逻辑依赖关系的实体(如程序分析和电路设计中的实体)方面发挥着基础性作用。本研究探讨了能够有效表达所需有向空间关系的有向图位置编码设计。我们首先提出了行走剖面,这是行走计数序列在有向图上的推广。我们识别出现有位置编码方法(包括对称化拉普拉斯PE、奇异值分解PE和磁拉普拉斯PE)在表达行走剖面能力上的局限性。为克服这些局限性,我们提出了多q磁拉普拉斯PE,该方法通过引入多个势因子扩展了磁拉普拉斯PE。这种简单变体被证明能够可证明地表达行走剖面。此外,我们将先前的基础不变且稳定的网络推广至处理从磁拉普拉斯分解得到的复域位置编码。我们的数值实验表明,结合稳定神经架构的多q磁拉普拉斯PE在预测有向距离/行走剖面、排序网络可满足性以及通用电路基准测试中均优于先前的位置编码方法(配合稳定网络)。我们的代码可在 https://github.com/Graph-COM/Multi-q-Maglap 获取。