Ai
7 Star 34 Fork 23

空無一悟/algorithms

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Main.java 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
空無一悟 提交于 2021-09-22 23:47 +08:00 . init
/***********************************************************
* @Description : 广度优先遍历解决单源路径问题
* @author : 梁山广(Laing Shan Guang)
* @date : 2019-08-09 16:12
* @email : liangshanguang2@gmail.com
***********************************************************/
package Chapter05BreadthFirstTraversal.Section3GraphBFSSingleSourcePath;
import Chapter02GraphExpress.Graph;
import Chapter02GraphExpress.ReadGraph;
import Chapter05BreadthFirstTraversal.Section2GraphBFS.GraphBFS;
public class Main {
public static void main(String[] args) {
String filePath = "src/main/java/Chapter05BreadthFirstTraversal/Section2GraphBFS/graph.txt";
Graph graph = new Graph(false);
ReadGraph.init(graph, filePath);
GraphBFSSingleSourcePath graphBFSSingleSourcePath = new GraphBFSSingleSourcePath(graph, 0);
System.out.println("广度优先遍历顺序结果是:" + graphBFSSingleSourcePath.getOrderList());
System.out.println("0 -> 3 : " + graphBFSSingleSourcePath.path(3));
System.out.println("0 -> 6 : " + graphBFSSingleSourcePath.path(6));
}
}
/**
* 输出结果是:
* <p>
* 顶点数V = 7, 边数E = 7
* 广度优先遍历顺序结果是:[0, 1, 3, 2, 6, 5, 4]
* 0 -> 3 : [0, 1, 3]
* 0 -> 6 : [0, 2, 6]]
*/
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lsgwr/algorithms.git
git@gitee.com:lsgwr/algorithms.git
lsgwr
algorithms
algorithms
master

搜索帮助