求多重邻接表的迪杰斯特拉算法

问题描述:

求多重邻接表的迪杰斯特拉算法
无向图的多重邻接表不是邻接矩阵!
1个回答 分类:综合 2014-12-14

问题解答:

我来补答
#define MAX_VERTEX_NUM 20 //最大顶点个数
#define MAX_NAME 10 //顶点信息的最大长度
#define MAX_INFO 80 //信息最大长度
#define TRUE 1
#define FALSE 0
typedef int VRType; //顶点类型
typedef char InfoType;
typedef char VertexType[MAX_VERTEX_NUM];
typedef enum{DG,DN,UDG,UDN}GraphKind; //有向图,有向网,无向图,无向网
typedef struct ArcCell
{
VRType adj;//顶点关系类型,对无权图用1或0
//表示相邻否;对带权图,为权值类型
InfoType *info;//该弧相关信息指针
}ArcCell,AdjMatrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM];
typedef struct
{
VertexType vex[MAX_VERTEX_NUM]; //顶点向量
AdjMatrix arcs; //邻接矩阵
int vexnum,arcnum; //图的当前顶点数,弧数
GraphKind kind; //图种类标志
}MGraph;
int LocateVex(MGraph G,VertexType v1)
{
int i;
for(i=0;i
 
 
展开全文阅读
剩余:2000