7 Star 34 Fork 23

空無一悟/algorithms

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
BFSTest.java 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
空無一悟 提交于 2021-09-22 23:47 +08:00 . init
/***********************************************************
* @Description : BFS在有向图中的测试,BFS直接使用无向图的即可,完全不用改
* @author : 梁山广(Liang Shan Guang)
* @date : 2019/12/24 19:27
* @email : liangshanguang2@gmail.com
***********************************************************/
package Chapter13DirectedGraph.Section02CommonAlgorithms;
import Chapter02GraphExpress.Graph;
import Chapter02GraphExpress.ReadGraph;
import Chapter05BreadthFirstTraversal.Section2GraphBFS.GraphBFS;
public class BFSTest {
public static void main(String[] args) {
String filepath = "src/main/java/Chapter13DirectedGraph/Section01BasicTest/无权图.txt";
Graph graph = new Graph(true);
ReadGraph.init(graph, filepath);
System.out.println(graph.isDirected() ? "该图是有向图" : "该图是无向图");
System.out.print("BFS遍历顺序:");
System.out.println(new GraphBFS(graph).getOrderList());
}
}
/**
* 顶点数V = 5, 边数E = 5
* 该图是有向图
* BFS遍历顺序:[0, 1, 2, 3, 4]
*/
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lsgwr/algorithms.git
git@gitee.com:lsgwr/algorithms.git
lsgwr
algorithms
algorithms
master

搜索帮助