public class Index {
static int count = 9;//结点个数
static int[][] gra = new int[9][9];//邻接矩阵数组
static {//初始化数组 设置0表示自身连接,65535不可能的权重(表示不连接)
gra[0] =new int[]{0,10,65535,65535,65535,11,65535,65535,65535};
gra[1] =new int[]{10,0,18,65535,65535,65535,16,65535,12};
gra[2] =new int[]{65535,18,0,22,65535,65535,65535,65535,8};
gra[3] =new int[]{65535,65535,22,0,20,65535,65535,16,21};
gra[4] =new int[]{65535,65535,65535,20,0,26,65535,7,65535};
gra[5] =new int[]{11,65535,65535,65535,26,0,17,65535,65535};
gra[6] =new int[]{65535,16,65535,65535,65535,17,0,19,65535};
gra[7] =new int[]{65535,65535,65535,16,7,65535,19,0,65535};
gra[8] =new int[]{65535,12,8,21,65535,65535,65535,65535,0};
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int k = -1;//存放当前选中的结点,去-1是可以的,图中每个节点必有连线,所有数组中肯定存在小于65535的数
int[] low = new int[count];//存放当前遍历结点后,与结点相连边最小的权重
int[] adjVex = new int[count];//存放当前选中的结点的上一个结点
for(int i=0;i"+"end:"+k);//打印
for(int i=1;i