class Vertex{ //顶点 public char lebel; public boolean visited; public Vertex(char lab){ lebel = lab; visited = false; } }
private final int maxVertices = 20 ; //最大顶点数 private Vertex vertexList[]; private int adjMatrix[][]; private int vertexCount; private Stack theStack;
public Graph(){ vertexList = new Vertex[maxVertices]; adjMatrix = new int[maxVertices][maxVertices]; vertexCount = 0; for(int y = 0 ; y < maxVertices ; y++){ for(int x = 0 ; x < maxVertices ; x ++){ adjMatrix[x][y] = 0; } } theStack = new Stack(); }
public void addVertex(char lab){ vertexList[vertexCount++]=new Vertex(lab); }