7 Star 34 Fork 23

空無一悟/algorithms

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Main.java 1.43 KB
一键复制 编辑 原始数据 按行查看 历史
空無一悟 提交于 2021-09-22 23:47 +08:00 . init
package Chapter04DFSInAction.Section10BiPartitionDetect;
import Chapter02GraphExpress.Graph;
import Chapter02GraphExpress.ReadGraph;
/***********************************************************
* @note :
* @author : l00379880 梁山广
* @version : V1.0 at 2019/8/8 11:23
***********************************************************/
public class Main {
private static void showResult(String filePath) {
Graph graph = new Graph(false);
ReadGraph.init(graph, filePath);
GraphDFSBiPartitionDetect graphDFSBiPartitionDetect = new GraphDFSBiPartitionDetect(graph);
System.out.println(graphDFSBiPartitionDetect.isBiPartition());
System.out.println("当前图" + (graphDFSBiPartitionDetect.isBiPartition() ? "是" : "不是") + "二分图");
}
public static void main(String[] args) {
String filePath = "src/main/java/Chapter04DFSInAction/Section10BiPartitionDetect/graph.txt";
showResult(filePath);
filePath = "src/main/java/Chapter04DFSInAction/Section10BiPartitionDetect/graph2.txt";
showResult(filePath);
filePath = "src/main/java/Chapter04DFSInAction/Section10BiPartitionDetect/graph3.txt";
showResult(filePath);
}
}
/**
* 结果输出:
*
* 顶点数V = 7, 边数E = 6
* true
* 当前图是二分图
* 顶点数V = 4, 边数E = 6
* false
* 当前图不是二分图
* 顶点数V = 4, 边数E = 4
* true
* 当前图是二分图
*/
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lsgwr/algorithms.git
git@gitee.com:lsgwr/algorithms.git
lsgwr
algorithms
algorithms
master

搜索帮助