java - Using a queue to solve TSP (Branch and Bound) -


i'm working on branch , bound algorithm traveling salesman problem , i've run little hitch. i'm using pretty standard queue nodes representing subsets of vertices (paths). i'm pretty sure have whole thing worked out, @ moment have public class queue, , underneath private class node, of properties: current path, lower bound, etc.

however, in main program, initialize queue of nodes , create 2 starting nodes, error "node cannot resolved type". assumed because within queue class , not accessible main program, when move out, errors everywhere else on items connected node.

i hope makes sense, i'm not sure how else explain it, else seems fine. here's snippet of code 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 tree         public int[] path;      //current path         public int bound;       //lower bound         public item item;                public node next;       //the next in path         public boolean inpath;  //checks see if vertex in current path         public int missingv;    //the vertex missing path      }` 

that declare node class, , use in 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();` 

in main, change node queue.node :

    queue<queue.node> pq = new queue<queue.node>();     queue.node u = pq.new node();     queue.node v = pq.new node(); 

i'd suggest putting node class in seperate file queue since apparently need manipulate instances of outside queue class.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -