English

A fast algorithm for All-Pairs-Shortest-Paths suitable for neural networks

Data Structures and Algorithms 2024-07-25 v2 Neurons and Cognition

Abstract

Given a directed graph of nodes and edges connecting them, a common problem is to find the shortest path between any two nodes. Here we show that the shortest path distances can be found by a simple matrix inversion: If the edges are given by the adjacency matrix AijA_{ij} then with a suitably small value of γ\gamma the shortest path distances are Dij=ceil(logγ[(IγA)1]ij) D_{ij} = \operatorname{ceil} \left( \log_{\gamma} {\left[ {\left({\mathbf{I}}-\gamma {\mathbf{A}}\right)^{-1}} \right]}_{ij} \right) We derive several graph-theoretic bounds on the value of γ\gamma, and explore its useful range with numerics on different graph types. Even when the distance function is not globally accurate across the entire graph, it still works locally to instruct pursuit of the shortest path. In this mode, it also extends to weighted graphs with positive edge weights. For a wide range of dense graphs this distance function is computationally faster than the best available alternative. Finally we show that this method leads naturally to a neural network solution of the all-pairs-shortest-path problem.

Keywords

Cite

@article{arxiv.2308.07403,
  title  = {A fast algorithm for All-Pairs-Shortest-Paths suitable for neural networks},
  author = {Zeyu Jing and Markus Meister},
  journal= {arXiv preprint arXiv:2308.07403},
  year   = {2024}
}

Comments

28 pages, 4 figures, see also https://github.com/markusmeister/APSP

R2 v1 2026-06-28T11:55:31.787Z