邻接表 public int getDegree(int i){VNode v = vexs[i];int count = 0;//入度for(ArcNode arc = v.firstArc;arc!=null;arc = arc.nextArc)count++;//出度for(VNode u: vexs)for(ArcNode arc = u.firstArc;arc!=null;arc= arc.nextArc)if(vexs[arc.adj
public int getDegree(int i){ VNode v = vexs[i]; int count = 0; //入度 for(ArcNode arc = v.firstArc;arc!=null;arc = arc.nextArc) count++; //出度 for(VNode u: vexs) for(ArcNode arc = u.firstArc;arc!=null;arc= arc.nextArc) if(vexs[arc.adjVex].equals(v)) count++; return count; }