Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • $\begingroup$ Thank you for your answer! Unfortunately I didn't specified myself clearly enough. You assumed, that graph will be as simple as my example, but it can be any graph i.e. there can be also roads 0->2, 1->3 etc. $\endgroup$ Commented May 20, 2014 at 1:14
  • $\begingroup$ Ya,as you didn't mention that before I assumed all the cities are connected in a linear fashion (the graph is a simple path). $\endgroup$ Commented May 20, 2014 at 1:21