|
|
@@ -1,4 +1,79 @@
|
|
|
package com.example.data_structure.domain;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+
|
|
|
public class Graph {
|
|
|
+ private boolean isDirected; //是否有向
|
|
|
+ private boolean isWeighted; //是否带权
|
|
|
+ private int nodeNum; //结点数
|
|
|
+ private int edgeNum;//边数
|
|
|
+ private ArrayList<String> nodeList; //各结点名称
|
|
|
+ private ArrayList<ArrayList<Boolean>> graph; //图中结点和边的连接关系
|
|
|
+ private ArrayList<ArrayList<Double>>weight;//各边权重
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 没有权重的图的构造方法
|
|
|
+ * @param isDirected
|
|
|
+ * @param nodeNum
|
|
|
+ * @param edgeNum
|
|
|
+ * @param nodeList
|
|
|
+ * @param graph
|
|
|
+ */
|
|
|
+ public Graph(boolean isDirected, int nodeNum, int edgeNum, ArrayList<String> nodeList, ArrayList<ArrayList<Boolean>> graph) {
|
|
|
+ this.isDirected = isDirected;
|
|
|
+ this.isWeighted=false;
|
|
|
+ this.nodeNum = nodeNum;
|
|
|
+ this.edgeNum = edgeNum;
|
|
|
+ this.nodeList = nodeList;
|
|
|
+ this.graph = graph;
|
|
|
+ this.weight=null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 带权图构造方法
|
|
|
+ * @param isDirected
|
|
|
+ * @param isWeighted
|
|
|
+ * @param nodeNum
|
|
|
+ * @param edgeNum
|
|
|
+ * @param nodeList
|
|
|
+ * @param graph
|
|
|
+ * @param weight
|
|
|
+ */
|
|
|
+ public Graph(boolean isDirected, boolean isWeighted, int nodeNum, int edgeNum, ArrayList<String> nodeList, ArrayList<ArrayList<Boolean>> graph, ArrayList<ArrayList<Double>> weight) {
|
|
|
+ this.isDirected = isDirected;
|
|
|
+ this.isWeighted = isWeighted;
|
|
|
+ this.nodeNum = nodeNum;
|
|
|
+ this.edgeNum = edgeNum;
|
|
|
+ this.nodeList = nodeList;
|
|
|
+ this.graph = graph;
|
|
|
+ this.weight = weight;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取计算最小生成树过程中每一步的结果,返回一个结果列表
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<Graph> getMinimalSpanningTree(){
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取广度优先遍历的结点遍历顺序
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<String> getBreadthFirstTraversal(){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取深度优先遍历的结点遍历顺序
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public ArrayList<String> getDepthFirstTraversal(){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
}
|