邻接表 邻接矩阵 结构体定义
使用邻接表时候的结构体定义
#include<stdio.h>
#include<iostream>
using namespace std;
#define MaxSize 100
typedef int VertexType;
typedef int EdgeType;
typedef struct ArcNode
{
int adjvex;
int weight;
struct ArcNode *nextarc;
}ArcNode;
typedef struct VNode
{
VertexType data;
ArcNode *firstarc;
}VNode;
typedef struct
{
VNode adjlist[MaxSize];
int n, e;
}AGraph
使用邻接矩阵时候的定义
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
#define INFINITY 65535
#define maxSize 50
#define OK 1
typedef int VertexType;
typedef int EdgeType;
typedef struct
{
VertexType vexs[maxSize];
EdgeType arc[maxSize][maxSize];
int n, e;
}MGraph;