1
$\begingroup$

Question:

Given a graph $G$, How can we find the shortest path from vertex $x$ to $y$ with odd length?

Note: The time complexity is important to me. Can we somehow modify Breadth-first Search to do the trick?

  • 0
    Do you need to use each edges at most once?2017-02-23
  • 0
    @Smylic yes! its like the shortest path problem... but the length should be odd!2017-02-23
  • 0
    That makes the problem harder. I can only tell you solution when double pass through an edge is allowed.2017-02-23
  • 0
    @Smylic what do you mean by double pass? u cound every 2 edges 1?2017-02-23
  • 1
    Let look at this graph: $G = (\{\,1, 2, 3, 4, 5, 6\,\}, \{\,\{\,1, 2\,\}, \{\,2, 3\,\}, \{\,3, 4\,\}, \{\,4, 5\,\}, \{\,5, 6\,\}, \{\,4, 6\,\}\,\})$. There is a [walk](http://mathworld.wolfram.com/Walk.html) of odd length from vertex 3 to vertex 1. But there is no [trail](http://mathworld.wolfram.com/Trail.html) of an odd length between these vertices. In greater graphs it is possible when there is a trail of an odd length, but traversing an edge twice allows you to get a shorter walk of an odd length.2017-02-23
  • 0
    @Smylic well, i'm sorry but that's not what i want2017-02-23

1 Answers 1

0

A very elegant answer to the question can be found here.


Alternatively, you could always do it with a MIP: use binary variables $x_{ij}$ that take value $1$ if and only if edge $(i,j)$ is used, and minimize $$ \sum_{(i,j)\in E} x_{ij} $$ subject to $$ \begin{cases} \mbox{usual flow constraints} \\ \sum_{(i,j)\in E} x_{ij}=2k+1\\ k \in \mathbb{N}\\ x_{ij}\in \{0,1\} \end{cases} $$

Of course, the complexity is exponential so that is a major flaw to this method if theoretic time complexity is important. But it would be interesting to see how computation times evolve in practice, as the implementation is straightforward.

  • 0
    Solution you post link to gives a shortest even walk, not a shortest even trail (see comments to this question).2017-02-24
  • 0
    I wrote that time complexity is important to me. I mentioned that the solution should be in linear time. I said "odd". With all of these, what is this answer??!!2017-02-25
  • 0
    Just sharing ideas, don't be so harsh..The link I posted gives a method for "even" paths, but if you read carefully it gives you "odd" paths at the same time (by considering vertices $(i',j')$). And yes, I agree the second method is off subject if you want linear time, but I put it there as an alternative, it is not my main answer.2017-02-25