有三个类,Node类,Edge类,Graph类,图采用邻接表的存储结构,
DFS的递归能明白,也能写出来,但是非递归的DFS,和BFS实在搞不懂,求指教,谢谢谢谢。测试路径为:// AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7 public class Node { private String name;
private boolean visited;

public Node(String name) {
super();
this.name = name;
this.visited = false;
}
// getter setter @Override
public int hashCode() {
////以name比较Node是否相等
}
@Override
public boolean equals(Object obj) {
//以name比较Node是否相等
}

}public class Edge { private Node start;
private Node end;
private int weight;
private Edge next;//getter setter
public Edge(Node start, Node end, int weight) {
super();
this.start = start;
this.end = end;
this.weight = weight;
}
} public class Graph { private HashMap<Node, Edge> map; public HashMap<Node, Edge> getMap() {
return map;
} public void setMap(HashMap<Node, Edge> map) {
this.map = map;
} public Graph() {
super();
map = new HashMap<>();
}

}