#include <stdio.h>
#include <stdlib.h>
#define MAX 1000
typedef struct SHORTRSTPATH_STRU
{
int size;//图中节点的个数
int**pathLen;//二位数组保存每对顶点中的最短路径长度
int **nextVex;//二维数组保存vi到vj最短路径上vi后续节点的下标
}ShortPath;
typedef struct GRAPHMATRIX_STRU
{
int size;
int **graph;
}GraphMatrix;
GraphMatrix* InitGraph(int num)
{
int i,j;
GraphMatrix *graphMatrix=(GraphMatrix*)malloc(sizeof(GraphMatrix));
graphMatrix->size=num;
graphMatrix->graph=(int**)malloc(sizeof(int*)*graphMatrix->size);
for(i=0;i<graphMatrix->size;i++)
graphMatrix->graph[i]=(int*)malloc(sizeof(int)*graphMatrix->size);
for(i=0;i<graphMatrix->size;i++)
{
for(j=0;j<graphMatrix->size;j++)
gra
利用floyd算法求最短路径长度与并输出路径
最新推荐文章于 2024-02-07 17:42:37 发布