7 Star 32 Fork 21

空無一悟 / algorithms

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Main.java 1013 Bytes
一键复制 编辑 原始数据 按行查看 历史
空無一悟 提交于 2021-09-22 23:47 . init
package Chapter05BreadthFirstTraversal.Section6GraphBFSCycleDetect;
import Chapter02GraphExpress.Graph;
import Chapter02GraphExpress.ReadGraph;
public class Main {
private static void showResult(String filePath) {
Graph graph = new Graph(false);
ReadGraph.init(graph, filePath);
GraphBFSCycleDetect graphBFSCycleDetect = new GraphBFSCycleDetect(graph);
System.out.println("当前图中" + (graphBFSCycleDetect.hasCycle() ? "有" : "无") + "环");
}
public static void main(String[] args) {
// graph有环
String filePath = "src/main/java/Chapter05BreadthFirstTraversal/Section6GraphBFSCycleDetect/graph.txt";
showResult(filePath);
// graph2.txt无环
filePath = "src/main/java/Chapter05BreadthFirstTraversal/Section6GraphBFSCycleDetect/graph2.txt";
showResult(filePath);
}
}
/**
* 输出结果
* <p>
* 顶点数V = 7, 边数E = 6
* 当前图中有环
* 顶点数V = 7, 边数E = 5
* 当前图中无环
*/
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lsgwr/algorithms.git
git@gitee.com:lsgwr/algorithms.git
lsgwr
algorithms
algorithms
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891