java实现深度优先搜索
package com.lishilin; import com.sun.istack.internal.NotNull; import java.util.*; public class Dfs { public static class Node implements Comparable<Node> { private String name; private TreeSet<Node> set = new TreeSet<>();//有序的集合 public Node() { } public Node(String name) { this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Set<Node> getSet() { return set; } public void setSet(TreeSet<Node> set) { this.set = set; } @Override public int compareTo(@NotNull Node o) {//排序规则 if(name.hashCode()>o.getName().hashCode()) return 1;