Search:

Type: Posts; User: Norm

Search: Search took 0.13 seconds.

  1. Replies
    18
    Views
    2,479

    Re: Dijkstra's code help

    Where are the distance values you want printed?

    Is this what is printed and where you want the distances included:

    return shortestPath[i].path;

    When you build the contents of path, you...
  2. Replies
    18
    Views
    2,479

    Re: Dijkstra's code help

    Where are the distance values kept? Where is the printing of the cities done?
    Can the location in the code that builds the String with the cities, access the distances and include them with the...
  3. Replies
    18
    Views
    2,479

    Re: Dijkstra's code help

    Yes it would do exactly the same. I don't think I said to print the path because it was already being printed. Leave off the .path and just print the element which will cause the toString() method...
  4. Replies
    18
    Views
    2,479

    Re: Dijkstra's code help

    That change was for use when debugging the program. You need to change the code so it calls the toString method and prints out what is returned.
    For example print the value of the shortestPath...
  5. Replies
    18
    Views
    2,479

    Re: Dijkstra's code help

    Start by changing this:

    //public String toString(){
    //return place + " " +weight;
    //}
    to this:

    public String toString(){
    return "<"+place + " " +weight + ">";
    }
  6. Replies
    18
    Views
    2,479

    Re: Dijkstra's code help

    Change what is saved in the NodeData class to include what you want to see printed.
    For debugging add a toString() method to NodeData that will return useful info to print out.
  7. Replies
    18
    Views
    2,479

    Re: Dijkstra's code help

    Where are those distance values available so you can use them when formatting the String for printing?
  8. Replies
    18
    Views
    2,479

    Re: Dijkstra's code help

    Can you post what the program prints now and add some comments to it showing what the problem is
    and show what you want the output to look like.
  9. Replies
    18
    Views
    2,479

    Re: Dijkstra's code help

    Do you have a design or algorithm for solving this problem? Given that, someone could help you fix your code so that it follows the algorithm.


    Where do you print the city names? Where is the...
Results 1 to 9 of 9