graph.java
来自「java Labyrinth game;Provides two kinds t」· Java 代码 · 共 48 行
JAVA
48 行
package src;
import java.util.LinkedList;
/*
* 图,用于产生一个图而深处优先遍历产生地图
*/
public class Graph {
private int thisCode;
private int stateOf=0;//用来标记元素的个数
LinkedList<Integer> conCode = new LinkedList<Integer>();//采用邻接表存储邻接点
XandY xandyInGraph = new XandY();
boolean vistied = false;
public void setxandyInGraph(int x,int y){
xandyInGraph.setX(x);
xandyInGraph.setY(y);
}
public XandY getxandyInGraph(){
return xandyInGraph;
}
public void addLink(Integer x){
/*
* 从起始点加入是为了可以用stateOf直接调用未被访问的元素
*/
conCode.offerFirst(x);
stateOf++;
}
public int getstateOf(){
return stateOf;
}
public int getLink(int k){
return conCode.get(k);
}
public Graph(int thisCode){//构造函数
this.thisCode=thisCode;
}
public void setthisCode(int thisCode){
this.thisCode=thisCode;
}
public int getthisCode(){
return thisCode;
}
public void setvistied(){
vistied = true;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?