有向图的邻接矩阵
#include
#define VerNum 100 /*最大顶点数设为100*/ typedef char VerType; /*顶点类型设为字符型*/ typedef int EdType; /*边的权值设为整型*/ typedef struct
{
VerType vexs[VerNum];
EdType edges[VerNum][VerNum];
int n, e; /* 顶点数和边数 */ }MGraph; /*Maragh是以邻接矩阵存储的图类型 */
void CreateMGraph(MGraph G) {
int i,j,k,w,m,z;
printf("请输入顶点数和边数(输入格式为:顶点数,边数):\n");
scanf("%d,%d",&(G.n),&(G.e));
printf("请输入顶点信息(输入格式为:顶点号。顶点下标号从0开始):\n");//顶点
的信息会出现在矩阵边界上。
for (i=0;i