#include
typedef int DataType;
#define MaxSize 20
#define MaxVertices 20
#define MaxWeight 10000
#include
#include
typedef struct {
DataType list[MaxSize];
int size;
}Seqlist;
typedef struct
{
SeqList Vertices;
int edge[MaxVertices][MaxVertices];
int numOfEdges;
}AdjMGraph;
void Initiate(AdjMGraph G, int n)
{
int i, j;
for(i = 0; i < n; i++)
for(j = 0; j < n; j++)
{
if(i == j) G->edge[i][j] = 0;
else G->edge[i][j] = MaxWeight;
}
G->numOfEdges = 0; /边的条数置为0*/
ListInitiate(&G->Vertices); /*顺序表初始化*/
}
void InsertVertex(AdjMGraph G, DataType vertex)
{
ListInsert(&G->Vertices, G->Vertices.size, vertex);
}
void InsertEdge(AdjMGraph *G, int v1, int v2, int weight)
{
if(v1 < 0 || v1 > G->Vertices.size || v2 < 0 || v2 > G->Vertices.size)
{ printf("参数v1或v2越界出错!\n");
exit(1);
}
G->edge[v1][v2] = weight;
G->numOfEdges++;
}
typedef struct
{
int row; //行下标
int col; //列下标
int weight; //权值
} RowColWeight;
void CreatGraph(AdjMGraph *G, DataType V[],int n,RowColWeight E[],int e)
/在图G中插入n个顶点信息V和e条边信息E*/
{
int i, k;
Initiate(G, n); /*顶点顺序表初始化*/
for(i = 0; i < n; i++)
InsertVertex(G, V[i]); /*顶点插入*/
for(k = 0; k < e; k++)
InsertEdge(G, E[k].row, E[k].col, E[k].weight);
}
void main (void)
{
AdjMGraph g1;
DataType a[]={'1','2','3','4','5','6'};
RowColWeight rcw[]={{0,1,3},{0,2,2},{0,3,6},{1,2,3},{2,3,6},{1,4,6},{2,4,4},{2,5,5},{
3,5,1},{4,5,1},{1,0,3},{2,0,2},{3,0,6},{2,1,3},{3,2,6},{4,1,6},{4,2,4},{5,2,5},
{5,3,1},{5,4,1}};
int n=6,e=10;
GreatGraph(&g1,a,n,rcw,e);
printf("顶点集合为:");
for(i=0;i<=g1.Vertices.size;i++)
printf("%c",g1.Vertices.list[i]);
printf("\n");
printf("权值集合为:\n");
for(i=0;i<=g1.Vertices.size;i++)
{
for(j=0;j<=g1.Vertices.size;j++)
printf("%5d",g1.edge[i][j]);
printf("\n");
}
}
Cannot open include file: 'AdjMGraph.h': No such file or directory
执行 cl.exe 时出错. 出现这样的问题该怎么解决了!!!