如果您需要使用本文档,请点击下载按钮下载!
如果您需要使用本文档,请点击下载按钮下载!
1 / 6
如果您需要使用本文档,请点击下载按钮下载!
#include<>
#include<>
#define MAX_VERTEX_NUM 20
#define MAX 32767
#define ERROR 0
#define OK 1
#define OVERFLOW -2
typedef int Status;
typedef char VertexType;
typedef int PathMatrix[ MAX_VERTEX_NUM][ MAX_VERTEX_NUM];
typedef int ShortPathTable[ MAX_VERTEX_NUM];
bool visited[MAX_VERTEX_NUM];
bool final[MAX_VERTEX_NUM];
typedef struct
{char adj;
int lowcost;
}closedge[MAX_VERTEX_NUM];
typedef struct ArcNode
{int adjvex;//弧所指向的顶点的位置
struct ArcNode *nextarc;//指向下一条弧的指针
int weight;//权重
//InfoType *info;//该弧相关信息的指针
}ArcNode;
typedef struct VNode
{VertexType data;//顶点信息
ArcNode *firstarc;
}VNode,AdjList[MAX_VERTEX_NUM];
typedef struct
{AdjList vertices;
int vexnum,arcnum;
int kind;
}ALGraph;
//--------------------------------------------------
//队列
typedef struct node
{int data;
struct node *next;
}QNode,*QueuePtr;
typedef struct
{QueuePtr front;
QueuePtr rear;
}LinkQueue;
//构造一个空队列
如果您需要使用本文档,请点击下载按钮下载!
如果您需要使用本文档,请点击下载按钮下载!
2 / 6
如果您需要使用本文档,请点击下载按钮下载!
Status InitQueue(LinkQueue &Q)
{==(QueuePtr)malloc(sizeof(QNode));
if(!) exit(OVERFLOW);
->next=NULL;
return OK;
}
//插入元素
Status EnQueue(LinkQueue &Q,int &e)
{QueuePtr p;
p=(QueuePtr)malloc(sizeof(QNode));
if(!p) exit(OVERFLOW);
p->d
邻接表prim算法 来自淘豆网m.daumloan.com转载请标明出处.