#include
#define MAX_VERTEX_NUM 20
#define INFINITY 32768
#define ERROR -1
typedef enum {DG,DN,UDG,UDN} GraphKind;
typedef char VertexData;
typedef struct ArcNode
{
int adj; /*权值类型*/
char info;
}ArcNode;
typedef struct{
VertexData vertex[MAX_VERTEX_NUM];
ArcNode arcs[MAX_VERTEX_NUM][MAX_VERTEX_NUM];/*邻接矩阵*/
int vexnum,arcnum;
//GraphKind kind;
}AdjMatrix;
int LocateVertex(AdjMatrix *G,VertexData v)
{
int j = ERROR,k;
for(k = 0;k< G -> vexnum;k ++)
{
if(G -> vertex[k] == v )
{
j = k;
break;
}
}
return (j);
}
void CreatDN(AdjMatrix *G)
{
int i,j,k,weight;
VertexData v1,v2;
G=(AdjMatrix *)malloc(sizeof(AdjMatrix));
scanf("%d,%d",&G->vexnum,&G->arcnum);
for(i = 0;i < G->vexnum;i++)
for(i = 0;i < G->vexnum;i++)
G->arcs[i][j].adj=INFINITY;
for(i = 0;i < G->vexnum;i++)
scanf("%c",&G->vertex[i]);
for(k = 0;k< G->arcnum;k ++)
{
scanf("%c %c %d",&v1,&v2,&weight);
i = LocateVertex(G,v1);
j = LocateVertex(G,v2);
G->arcs[i][j].adj = weight;
}
//显示所有的结点信息
i=0;
while(G->vertex[i])
{
printf("%c",G->vertex[i]);
i ++;
}
// return G;
}
int main()
{
AdjMatrix *A=(AdjMatrix *)malloc(sizeof(AdjMatrix));
CreatDN(A);
return 0;
}