3

I am interested in two problems, which seem to be related, solving each will advance me in other possible directions.

In both problems, $G=(V,E)$ is a positively-weighted undirected graph. Denote its weight function by $w$.

Having $w$, a weight-distance between $2$ vertices is the smallest sum of weights on a path between these vertices. The edge-distance is simply the number of edges between them, on a path that will ignore the weight function and will only count the number of edges.

The first problem: For any $v\in V$, find the weight-distance to all $u\in V$ such that there exists a vertex $z\in V$ for which: $(v,z)(z,u)\in E$. Basically, its like All-Pairs Shortest Path, just for pairs of vertices within edge-distance exactly $2$. Only these pairs are of interest to me, and I would like the algorithm to be as nearly to quadratic time as possible (Say, $|V|^{\frac{5}{2}}$ is already inefficient for me).

My attempt was a sort of Dijkstra combined with a BFS (or the first two levels of a BFS tree), but this leads to $|E|$ time, which makes it $|V||E|$, which is way inefficient for me.

The second problem might be even harder. Consider $G$. The weight of a triangle is simply the sum of its' edges' weights. I want to find for each vertex its minimal weight triangle. As I am not attempting to enumerate all triangles, I do believe this can be solved faster than $|E|^{\frac{3}{2}}$ for triangle enumeration.

For this problem, I have considered attempting a degeneracy-based approach, by trying to sort edges and disqualifying edges that are "too heavy" - but this never gave fruit to an actual algorithm. The total runtime here should also likely be $|V|^2$ or very near, $|V|^{\frac{5}{2}}$ is too heavy.

I suspect the second problem I presented might be even harder then the first, therefore I am not aware if such algorithms can be made, or if it would apply certain other problems are too easy from what they are believed to be.

A general note is that the graph might be dense, so $|V||E|$ is too much time for either one.

Additionally, I would like to avoid matrix multiplication algorithms, yet if the runtime (without MM) is an expected runtime, that is acceptable, as I believe having a deterministic algorithm without MM might be too hard. So a random algorithm (without MM) with an expected runtime of as near $|V|^2$ as possible is also efficient.

Mařík Savenko
  • 364
  • 1
  • 12

1 Answers1

0

Your first problem basically boils down to a transitive closure in a graph. Here, matrix multiplication can be used. The best-known algorithm to date has a complexity of $n^{2.371552}$. In my opinion, finding a quadratic algorithm for this problem is as hard as finding the same for the matrix multiplication problem.

Once you have the 2-edge-distance all-pair-shortest-path matrix, you can combine (add and take min) that with the weighted adjacency matrix to solve the triangle problem. The time complexity of just this step will be $O(n^2)$. The first step remains the dominant one.


UPDATE
Taking inspiration from how network routing tables are updated (a distributed APSP approach), here is an approach for the first problem. For each vertex $v$, we maintain an $O(n)$ storage. Now for each vertex $v$, inform all of its neighbors of its presence, and thus we have all $1$-edge-distances with us. This takes a total of $O(|V| + |E|)$ time, which is at most $O(n^2)$. Now each vertex broadcasts its $1$-edge-distance table to all of its neighbours. Thus, at each vertex, we get atmost $n$ such tables. These tables can now be merged to compute the required $2$-edge-distance paths. The expected running time of this step is $O(n \times \tilde{d^2})$, where $\tilde{d}$ is the average degree of the graph, which is typically small compared to $n$ in practical graphs.

codeR
  • 1,983
  • 7
  • 17