Question

I'm working on a Branch and Bound algorithm for the Traveling Salesman Problem and I've run into a little hitch. I'm using a pretty standard Queue with Nodes representing subsets of vertices (paths). I'm pretty sure I have the whole thing worked out, but at the moment I have the public class Queue, and underneath that the private class Node, with all of its properties: the current path, the lower bound, etc.

However, in my main program, I initialize the Queue of nodes and create the two starting nodes, but I get the error "Node cannot be resolved to a type". I assumed this was because it was within the Queue class and not accessible to the main program, but when I move it out, I get errors everywhere else on items that are connected to the node.

I really hope this makes sense, I'm not sure how else to explain it, but everything else seems to be fine. Here's a snippet of my code for clarification:

`public class Queue<Item> implements Iterable<Item> {
    private int N;         // number of elements on queue
    private Node first;    // beginning of queue
    private Node last;     // end of queue

    // helper linked list class
    public class Node {
        public int level;       //level on the tree
        public int[] path;      //current path
        public int bound;       //lower bound
        public Item item;       
        public Node next;       //the next in the path
        public boolean inPath;  //checks to see if the vertex is in the current path
        public int missingV;    //the vertex that is missing from the path

    }`

That is where I declare the Node class, and this is where I actually use it in my main program:

`public static void main(String args[]) {
    int n = 4;
    int[][] W = new int[][] {{0,2,4,7},{2,0,7,3},{4,7,0,5},{6,3,5,0}};
    int[] opttour;
    Queue<Node> PQ = new Queue<Node>();
    Node u = new Node();
    Node v = new Node();`

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top