{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/what-are-good-positional-encodings-for","title":"What Are Good Positional Encodings for Directed Graphs?","arxiv_id":"2407.20912","date":"2024-07-30","proceeding":null,"authors":["Yinan Huang","Haoyu Wang","Pan Li"],"abstract":"Positional encodings (PEs) are essential for building powerful and expressive graph neural networks and graph transformers, as they effectively capture the relative spatial relationships between nodes. Although extensive research has been devoted to PEs in undirected graphs, PEs for directed graphs remain relatively unexplored. This work seeks to address this gap. We first introduce the notion of Walk Profile, a generalization of walk-counting sequences for directed graphs. A walk profile encompasses numerous structural features crucial for directed graph-relevant applications, such as program analysis and circuit performance prediction. We identify the limitations of existing PE methods in representing walk profiles and propose a novel Multi-q Magnetic Laplacian PE, which extends the Magnetic Laplacian eigenvector-based PE by incorporating multiple potential factors. The new PE can provably express walk profiles. Furthermore, we generalize prior basis-invariant neural networks to enable the stable use of the new PE in the complex domain. Our numerical experiments validate the expressiveness of the proposed PEs and demonstrate their effectiveness in solving sorting network satisfiability and performing well on general circuit benchmarks. Our code is available at https://github.com/Graph-COM/Multi-q-Maglap.","url_abs":"https://arxiv.org/abs/2407.20912v2","url_pdf":"https://arxiv.org/pdf/2407.20912v2.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"what-are-good-positional-encodings-for","repo_url":"https://github.com/graph-com/multi-q-maglap","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[],"methods":[{"method_slug":"lapeigen","method_name":"LapEigen"},{"method_slug":"laplacian-pe","method_name":"Laplacian PE"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2407.20912","atlas_url":"https://app.syntology.ai/?focus=2407.20912","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2407.20912"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/graph-com/multi-q-maglap","reach":{"status":"ok"}}],"summary":{"ran":6},"by_repo_kind":{"official":{"samples":6,"ran":6,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":6,"samples":[{"code_sha256_prefix":"f8a74584456c51a5","entry":"add_node_attr","repo":"graph-com/multi-q-maglap","repo_kind":"official","path":"EDA_benchmark/maglap/get_mag_lap.py","file_url":"https://github.com/graph-com/multi-q-maglap/blob/HEAD/EDA_benchmark/maglap/get_mag_lap.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f8a74584456c51a5"}},{"code_sha256_prefix":"135e06774f433c91","entry":"complex_norm","repo":"graph-com/multi-q-maglap","repo_kind":"official","path":"EDA_benchmark/maglap/handle_complex.py","file_url":"https://github.com/graph-com/multi-q-maglap/blob/HEAD/EDA_benchmark/maglap/handle_complex.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"135e06774f433c91"}},{"code_sha256_prefix":"5475be450fc6d103","entry":"get_mag_laplacian","repo":"graph-com/multi-q-maglap","repo_kind":"official","path":"EDA_benchmark/maglap/get_mag_lap.py","file_url":"https://github.com/graph-com/multi-q-maglap/blob/HEAD/EDA_benchmark/maglap/get_mag_lap.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"5475be450fc6d103"}},{"code_sha256_prefix":"3b8663605257ffae","entry":"get_walk_profile_v2","repo":"graph-com/multi-q-maglap","repo_kind":"official","path":"EDA_benchmark/maglap/get_mag_lap.py","file_url":"https://github.com/graph-com/multi-q-maglap/blob/HEAD/EDA_benchmark/maglap/get_mag_lap.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3b8663605257ffae"}},{"code_sha256_prefix":"82306e15fb61d3b9","entry":"pairwise_angles","repo":"graph-com/multi-q-maglap","repo_kind":"official","path":"EDA_benchmark/maglap/handle_complex.py","file_url":"https://github.com/graph-com/multi-q-maglap/blob/HEAD/EDA_benchmark/maglap/handle_complex.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"82306e15fb61d3b9"}},{"code_sha256_prefix":"62c5c6a431885f71","entry":"sinusoid_position_encoding","repo":"graph-com/multi-q-maglap","repo_kind":"official","path":"model/graph_classfication_model_sorting.py","file_url":"https://github.com/graph-com/multi-q-maglap/blob/HEAD/model/graph_classfication_model_sorting.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"62c5c6a431885f71"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}