how to identify the second shortest path in an unweighted undirected graph

$\begingroup$

Given an unweighted and undirected graph, can I identify the second best shortest path from every node to every other node in polynomial time? When I say the second best, as long as one edge is different than the edges existing in the first shortest path, it is acceptable. This also implies that the length of the paths can be equal.

If so, what is the algorithm that I should use?

$\endgroup$ 5

1 Answer

$\begingroup$

A naive way that would work is the following: Let $P$ be a shortest path from $u$ to $v$. For each $e \in P$ find the shortest path $P_{e}$ in $G \setminus \{e\}$. Then the shortest of the $P_{e}$s, $e \in P$, is a second shortest path from $u$ to $v$.

$\endgroup$ 3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like