摘要:
判断一个图是否为无环图: 完整代码 public class Cycle { private boolean[] marked; private int[] edgeTo; private Stack<Integer> cycle; /** * Determines whether the undi 阅读全文
摘要:
使用深度优先搜索查找图中的连通分量:思想就是在深度优先搜索的基础上,在加上一个连通分量的数值标识( count),用于统计有几个连通分量。 public class CC { private boolean[] marked; // marked[v] = has vertex v been mar 阅读全文
摘要:
广度优先搜索代码: public class BreadthFirstPaths { private static final int INFINITY = Integer.MAX_VALUE; private boolean[] marked; // marked[v] = is there an 阅读全文
摘要:
深度优先搜索的代码: public class DepthFirstSearch { private boolean[] marked; // marked[v] = is there an s-v path? private int count; // number of vertices con 阅读全文