Draft

The shortest path between two cities

Description
Loading description...
Algorithms
Graph Theory
  • Please sign in or sign up to leave a comment.
  • Voile Avatar

    The random tests are a joke: it reuses the same graph used by the fixed tests for the entire test suite and only chooses random cities between 16 possible cities. This can barely be called random.

  • Voile Avatar

    It is not explained what the 3rd argument of findShortestWay does, and it is always supplied with 0. Is it the author solution's recursion base argument?

  • Voile Avatar

    Dijkstra's algorithm is a duplicate to existing katas.

  • siebenschlaefer Avatar

    The solution setup is class Node { /*...*/ } but the tests want a class Graph. "storage [...] contains [...] edges of this vertex as values of this vertex." I don't understand that. "Should contain method add()" Why do you require this method when it is not called in the three main tests? Why do you pass 0 as a third argument to findShortestWay? The random tests just call findShortestWay twice and compare the results. Better compare with your own model solution. A native speaker should go over the description.

    Also: You start with cities and distances, then continue with a generic undirected graph (vertices, edges, weights). You should mention that all weights are non-negative or Dijkstra won't work.

    • titelhalter Avatar

      Thank you for your feedback! I changed the solution setup. Initially I called class Node but then decided to rename it and changed description and test cases, however, unfortunately, forgot about the setup.

      "storage [...] contains [...] edges of this vertex as values of this vertex." - for example, if storage: {"A": {"B: 500", "C": 300}} it means that point "A" is connected with two point: "B" (distance between them 500) and point "C" (distance is 300). Of course, in this example storage also should contain keys "C" and "B" because since graph is undirected, you can travel both ways. So, the whole property should be {"A": {"B: 500", "C": 300}, "B": {"A": 500}, "C": {"A": 300}}.

      "Should contain method add()" - well, you have got a point here. It is not really required for the solution, but I thought about giving some ideas of how the problem can be solved.

      "Why do you pass 0 as a third argument to findShortestWay?" - I do not require others to do that, so did not mentioned in the description. Personally, I use it to set up the initial value of starting point in Dijkstra, and for recursive call handle this argument in other manner.

      Well, I start the description mentioning about graphs. All the story about cities is just for making the problem description a little lively, because I thought that problem for, lets say, begginners in programming since all experienced developers for sure really keen on graphs, DFS, BFS and so on. So probably for these begginers description containing boring math terms would not be very inspiring, so I desided to make less abstractive and more real life related

      I do not really get a point random test issue. I am sorry that is my first kata, it is open for contribution and if anyone would be so kind to help me make it better, I will very appreciate that.

    • siebenschlaefer Avatar

      "storage [...] contains [...] edges of this vertex as values of this vertex.": I should've phrased that differently. It's easy to understand by looking at the tests, but this part of the description should be rephrased to make it more understandable.

      Look at other katas. Most of them have a model solution in the tests and the random tests just call the user's solution and that model solution and compare the results. I would have done that for you but you unchecked "Allow contributors".

    • titelhalter Avatar

      I think I might understand what you mean with random tests, so I changed it now. Anyway, contributors are allowed now, so I would be very pleased if you have a look

  • ZED.CWT Avatar

    Needs Random Tests.

  • ZED.CWT Avatar

    Missing sample tests.