基本思想:对于有n个顶点的图,用一维数组vexs[n]存储顶点信息,用二维数组A[n][n]存储顶点之间关系的信息。该二维数组称为邻接矩阵。在邻接矩阵中,以顶点在vexs数组中的下标代表顶点,邻接矩阵中的元素A[i][j]存放的是顶点i到顶点j之间关系的信息。
vexs[n]={0,1...8}
A[i][j]={0,1,1,0,0,0,0,0,
`````````1,0,0,1,1,0,0,0,
`````````1,0,0,0,0,1,0,0,
`````````0,1,0,0,0,0,0,1,
`````````0,1,0,0,0,0,0,1,
`````````0,0,1,0,0,0,1,0,
`````````0,0,1,0,0,1,0,0,
`````````0,0,0,1,1,0,0,0
}
结果有了就好写了吧
[此贴子已经被作者于2017-12-17 18:26编辑过]