代码拉取完成,页面将自动刷新
/***********************************************************
* @Description : 哈密尔顿路径测试:起点选择地不同会影响哈密尔顿路径的查找
* @author : 梁山广(Liang Shan Guang)
* @date : 2019/12/20 23:25
* @email : liangshanguang2@gmail.com
***********************************************************/
package Chapter09HamiltonLoop.Section5HamiltonPath;
import Chapter02GraphExpress.Graph;
import Chapter02GraphExpress.ReadGraph;
import Chapter09HamiltonLoop.Section1to4HamiltonLoop.GraphDFSHamiltonLoop;
import java.util.List;
public class Main {
public static void main(String[] args) {
// 连通图,前序遍历
String filePath = "src/main/java/Chapter09HamiltonLoop/Section5HamiltonPath/graph.txt";
Graph graph = new Graph(false);
ReadGraph.init(graph, filePath);
System.out.print("起始点为0时哈密尔顿路径详情为:");
List<Integer> path = new GraphDFSHamiltonPath(graph, 0).getPath();
System.out.println(path);
path = new GraphDFSHamiltonPath(graph, 1).getPath();
System.out.print("起始点为1时哈密尔顿路径详情为:");
System.out.println(path);
}
}
/**
* 顶点数V = 4, 边数E = 4
* 起始点为0时哈密尔顿路径详情为:[0, 2, 1, 3]
* 起始点为1时哈密尔顿路径详情为:[]
*/
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。