私は巡回セールスマン問題の分枝限定アルゴリズムに取り組んでいますが、少し問題が発生しました。頂点(パス)のサブセットを表すノードを持つかなり標準的なキューを使用しています。私はすべてがうまくいったと確信していますが、現時点ではパブリッククラスのキューがあり、その下にプライベートクラスのノードとそのすべてのプロパティ(現在のパス、下限など)があります。
ただし、メインプログラムで、ノードのキューを初期化し、2つの開始ノードを作成しましたが、「ノードをタイプに解決できません」というエラーが表示されます。これは、Queueクラス内にあり、メインプログラムにアクセスできないためだと思いましたが、移動すると、ノードに接続されているアイテムで他のすべての場所でエラーが発生します。
これが理にかなっていることを本当に願っています。他にどのように説明すればよいかわかりませんが、他のすべては問題ないようです。明確にするために、私のコードのスニペットを次に示します。
`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
}`
ここでNodeクラスを宣言し、メインプログラムで実際に使用します。
`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();`