www.pudn.com > 距离矢量路由模拟.rar > Graph.java~1~


package rooter; 
 
class Graph 
   { 
   private final int MAX_VERTS = 20; 
   private final int INFINITY = 1000000; 
   private Vertex vertexList[]; // list of vertices 
   private int adjMat[][];      // adjacency matrix 
   private int nVerts;          // current number of vertices 
   private int nTree;           // number of verts in tree 
   private DistPar sPath[];     // array for shortest-path data 
   private int currentVert;     // current vertex 
   private int startToCurrent;  // distance to currentVert 
// ------------------------------------------------------------- 
   public Graph()               // constructor 
      { 
      vertexList = new Vertex[MAX_VERTS]; 
                                         // adjacency matrix 
      adjMat = new int[MAX_VERTS][MAX_VERTS]; 
      nVerts = 0; 
      nTree = 0; 
      for(int j=0; j