Probably i've an answer for this problem, but i'm not sill sure that it works.
It is not important to "find" the two path, the only important thing is to "know" if they exist or not. I don't think that this is an NP complete problem.
So, take the adjacency matrix $\textbf A$. We can easily suppose that it is filled with 0,1 value. (0 = no edge; 1 = there is an edge)
Let's use the following algebra with 3 values (0,1,2), where everything works as usual except: $2+\text{<something>} = 2$; $2*\text{<whatever greater than 0>} = 2$
So, if there are two paths of same length from $i,j$ i'm expecting that there is a value $p$ such that $(\textbf A^p)_{i,j} = 2$.
Let $n$ is the number of vertex in the graph (or, let's say, that $\textbf A$ has dimension $n\times n$). I don't know the value of $p$, but if i iterate $\textbf A$ by multiplying with itself for at most $n^2$ i should find the answer. (so, $p<n^2$)
(the sense is that i check $\text A$, then i check $\text A^2$, then i check $\text A^3$ and so on...)
here is my argumentation:
- if the two paths are simple paths, well, it works; if there are, at most i have to iterate $n$ times.
- If there is at least one neasted cycle or there is a path with two cycles, well, i have to find the least common multiple (LCM). $n^2$ is a bigger value for sure and in less than $n^2$ times if there is i should have to find them.
- If the two paths are two distinct paths, both with one cycle, then it's more or less similar to finding a solution for this two equation: $\alpha + \beta m = \gamma + \delta k$, where $m$ and $k$ are the length of these two distinct cycles.
Matrix multiplication $\text A^q$, as defined above, says "is there a path from $i$ to $j$ whose length is $q$?" So, if $\textbf A^q$ is grater than $1$ it means that there are more paths leading from $i$ to $j$.
By iterating the matrix $n^2$ times we pass through all the possible combination of $\delta$ and $\beta$. Indeed, $LCM(a,b)$ is defined as $(a*b)/GCD(a,b)$ and no cycle can be greater than $n$.
I stop to iterate once i found $(\textbf A^p)_{i,j} = 2$.
am i wrong?