クラスの幅優先検索と深さ優先検索の実装を作成していますが、コンパイル時に理解できないエラーが発生します。エラーは次のとおりです。
シンボル: 変数 aList
場所: クラス java.lang.Object for(graphNode ノード: map.get(i).aList){
aList 変数は、ノードが対応するグラフでアタッチされているノードを含むすべてのノードに格納される TreeSet です。上記のメイン メソッドでまったく同じ構文を使用していますが、エラーは発生しません。また、traverse メソッドでマップからすべてのノードを出力すると、本来あるべき graphNode 値ではなく、整数キーが出力されました。私は今とても混乱しています。助けてくれてありがとう。
import java.util.*;
import java.io.*;
public class HW1 {
public static void main (String[] args) throws Exception {
    Scanner sc = new Scanner(new File(args[0]));
    sc.useDelimiter("(\\s)"); // divide up by whitespcae
    TreeMap<Integer, graphNode> map = new TreeMap<Integer, graphNode>();
    int totalNodes = Integer.parseInt(sc.next());
    int totalEdges = Integer.parseInt(sc.next());
    // Fill up the map with nodes
    for(int i = 1; i <= totalNodes ; i++) {
        map.put(i, new graphNode(i, null, 10000));
    }
   // Add all the edges to the adjacency list
    while(sc.hasNext()){
        int start = Integer.parseInt(sc.next());
        int end = Integer.parseInt(sc.next());
         graphNode startNode = map.get(start);
         graphNode endNode = map.get(end);
         if(!startNode.aList.contains(endNode)){
            startNode.aList.add(endNode);
         }
         if(!endNode.aList.contains(startNode)){
            endNode.aList.add(startNode); 
        }
    }
    for(int i = 1; i <= map.size(); i++){
        for(graphNode node: map.get(i).aList){
            System.out.print(node.value+" ");
        }
        System.out.println("");
    } 
    traverse(map);
}
public static void traverse(TreeMap map){
        for(int i = 1; i <= map.size(); i++){
            for(graphNode node: map.get(i).aList){
                System.out.print(node.value+" ");
            }
            System.out.println("");
        } 
}
}
import java.util.*;
import java.io.*;
public class graphNode implements Comparable<graphNode> {
int value;
int distance;
graphNode prev;
TreeSet<graphNode> aList;
String color;
public graphNode(int value, graphNode prev, int distance) {
    this.value = value;
    this.prev = prev;
    this.distance = distance;
    aList = new TreeSet<graphNode>();
    String color = "white";
}
public String toString() {
    return value + "";
}
public int compareTo(graphNode other) {
    if (this.value < other.value){
        return -1;
    }else if (this.value == other.value){
        return 0;
    }else{
        return 1;
    }
}
}