1.两种存储结构(邻接表和邻接矩阵)
#define INF 32767
#define MAXV 100
typedef char InfoType;
typedef struct
{
int no;
InfoType info;
} VertexType;
typedef struct
{
int edges[MAXV][MAXV];
int n,e;
VertexType vexs[MAXV];
} MatGraph;
typedef struct ANode
{
int adjvex;
struct ANode *nextarc;
int weight;
} ArcNode;
typedef struct Vnode
{
InfoType info;
int count;
ArcNode *firstarc;
} VNode;
typedef struct
{
VNode adjlist[MAXV];
int n,e;
} AdjGraph;
2.图的基本运算
#include <stdio.h>
#include <malloc.h>
#include "graph.h"
void CreateMat(MatGraph &g,int A[MAXV][MAXV],int n,int e)
{
int i,j;
g.n=n; g.e=e;
for (i=0;i<g.n;i++)
for (j=0;j<g.n;j++)
g.edges[i][j]=A[i][j];
}
void DispMat(MatGraph g)
{
</