Table of Contents
Fetching ...

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

Zeyu Jing, Markus Meister

TL;DR

This work introduces the R-distance, a resolvent-based proxy for all-pairs shortest-path distances on directed graphs, defined as $R_{ij}(\gamma)=\log_{\gamma}\big[(\mathbf{I}-\gamma\mathbf{A})^{-1}\big]_{ij}$, which converges to the true distance $D_{ij}$ as $\gamma\to 0$. It shows how this quantity naturally arises from an analog neural network with recurrent feedback and derives rigorous bounds on the gain $\gamma$ that separate global accuracy from local usefulness, extending the approach to weighted graphs with positive weights. The authors provide both asymptotic results and finite-gain analyses, including sufficient conditions and bounds for trees and general graphs, and demonstrate that the R-distance can guide greedy descent even when not globally exact. They discuss digital-implementation considerations, including precision limitations and computational complexity, arguing that the method offers a practical speedup on dense graphs and a compelling neuromorphic interpretation, while acknowledging limitations due to finite precision and path redundancy. Overall, the paper presents a novel, resolvent-based APSP method with theoretical guarantees and potential neuromorphic applications, bridging matrix inversion, graph distances, and neural-network-inspired computation.

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 $A_{ij}$ then with a suitably small value of $γ$ the shortest path distances are $$ D_{ij} = \operatorname{ceil} \left( \log_γ {\left[ {\left({\mathbf{I}}-γ{\mathbf{A}}\right)^{-1}} \right]}_{ij} \right)$$ We derive several graph-theoretic bounds on the value of $γ$, 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.

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

TL;DR

This work introduces the R-distance, a resolvent-based proxy for all-pairs shortest-path distances on directed graphs, defined as , which converges to the true distance as . It shows how this quantity naturally arises from an analog neural network with recurrent feedback and derives rigorous bounds on the gain that separate global accuracy from local usefulness, extending the approach to weighted graphs with positive weights. The authors provide both asymptotic results and finite-gain analyses, including sufficient conditions and bounds for trees and general graphs, and demonstrate that the R-distance can guide greedy descent even when not globally exact. They discuss digital-implementation considerations, including precision limitations and computational complexity, arguing that the method offers a practical speedup on dense graphs and a compelling neuromorphic interpretation, while acknowledging limitations due to finite precision and path redundancy. Overall, the paper presents a novel, resolvent-based APSP method with theoretical guarantees and potential neuromorphic applications, bridging matrix inversion, graph distances, and neural-network-inspired computation.

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 then with a suitably small value of the shortest path distances are We derive several graph-theoretic bounds on the value of , 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.
Paper Structure (24 sections, 5 theorems, 65 equations, 4 figures)

This paper contains 24 sections, 5 theorems, 65 equations, 4 figures.

Key Result

Theorem 1

For any unweighted directed graph, the R-distance is globally correct (Eqn eq:rounded-distance-function) only if the following inequality is satisfied: where $S_{ij}$ is the number of distinct shortest paths from $j$ to $i$.

Figures (4)

  • Figure 1: Analog circuit to compute R-distances.A: Each of the linear units (triangles) receives input $w_i$ and generates output $v_i=\gamma w_i$. The input is combined from an external drive $u_i$ and feedback from the outputs through the connections $A_{ij}$. B: Example of a directed unweighted graph with 4 nodes and the corresponding adjacency matrix $A_{ij}$.
  • Figure 2: Performance of the R-distance. Each row represents a family of graphs illustrated by the icon on the left, with node numbers given in the legend. Global: Global performance: fraction of distances between nodes predicted correctly by Eqn \ref{['eq:rounded-distance-function']}, as a function of the gain parameter $\gamma$. Local: Local performance: fraction of successors predicted correctly according to Eqn \ref{['eq:descent']}. A: Global performance on graphs representing the Towers-of-Hanoi game. Dotted lines show the cutoff imposed by machine precision, according to Eqn \ref{['eq:gamma-precision']}. F: as in A, but for local performance. Note the valid range of $\gamma$ extends further to the right. B, G As in A and E, but for grid graphs: The nodes lie on a square Cartesian grid and each node connects to the 4 nearest neighbors. C, H Same, but for binary tree graphs, in which each node connects to 2 child nodes up to a certain number of levels. D, I Same, but for dense random graphs, in which each pair of nodes is connected with probability 0.5. I inset: Dotted lines indicate the critical gain, Eqn \ref{['eq:critical-gain']}. E, J Same, but for graphs following a power law degree distribution (exponent = 3).
  • Figure 3: The R-distance on weighted graphs. Results on a dense graph (as in Fig \ref{['fig:performance']}D,I) with random positive edge weights. A: The R-distance plotted against the true graph distance. $V=1000$ vertices, $p=0.5$ edge probability, edge weights range from 1 to 100 with log-uniform distribution. $\gamma = 10^{-7}$. Note high correlation coefficient $r^2$. B: Global performance. The correlation coefficient $r^2$ between R-distance and true graph distance, for graphs of various sizes ($V$ in legend) as a function of the gain $\gamma$. Note y-axis scale is close to 1. C: Local performance. The fraction of correct successors predicted by the R-distance. At $\gamma < 10^{-8}$ all 1 million successors in the $V=1000$ graph are predicted correctly.
  • Figure 4: Run times to compute distance functions. The run times for 3 conventional APSP algorithms, compared to that for the R-distance. The algorithms are Floyd-Warshall, Dijkstra, and Johnson, as implemented in the Python package scipy. A: Dense graphs (random unweighted with edge probability 0.5) with varying node numbers. All run times are divided by that for the R-distance. Dotted line: equality. Mean over 25 runs, bars indicate standard error. B: As in (A) for sparse graphs (binary tree). Note for all these graphs the conventional APSP algorithms are slower than the R-distance.

Theorems & Definitions (13)

  • Example 4.1
  • Theorem 1
  • proof
  • Example 4.2
  • Theorem 2
  • proof
  • Theorem 3
  • proof
  • Theorem 4
  • proof
  • ...and 3 more