拓扑排序课程设计

来源:百度知道 编辑:UC知道 时间:2024/05/10 09:10:40

#include<stdio.h>
#include<stdlib.h>
#include<iostream.h>
#define MAX_VEXTEX_NUM 20
#define M 20
#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10
#define OK 1
#define ERROR 0

typedef char ElemType;
typedef struct ArcNode
{
int adjvex; //该弧所指向的顶点的位置
struct ArcNode *nextarc; //指向下一条弧的指针
}ArcNode;

typedef struct VNode
{
char data; //顶点信息
ArcNode *firstarc; //指向第一条依附该顶点的弧的指针
}VNode,AdjList[MAX_VEXTEX_NUM];

typedef struct
{
AdjList vertices;
int vexnum, arcnum; //图的当前顶点数和弧数
}ALGraph;

typedef struct //构件栈
{
ElemType *base;
ElemType *top;
int stacksize;
}SqStack;

void InitStack(SqStack *); //函数声明
int Pop(SqStack *, ElemType &);
void Push(SqSt