#include "stdio.h"
#include "stdlib.h"
#include "io.h"
#include "math.h"
#include "time.h"
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
#define MAXVEX 100 /* 最大顶点数,应由用户定义 */
#define INFINITY 65535
typedef
int Status;
typedef
char VertexType;
typedef
int EdgeType;
typedef
struct{
VertexType vers[MAXVEX];
EdgeType arc[MAXVEX][MAXVEX];
int numNodes,numEdges;
}MGraph;
void CreateMGraph(MGraph *G){
int i,j,k,w;
printf(
"输入顶点数和边数: ");
scanf(
"%d,%d",&G->numNodes,&G->numEdges);
for(i=
0,i<G->numNodes;i++)
for(j=
0;j<G->numNodes;j++)
G->arc[i][j]=INFINITY;
for(k=
0;k<G->numEdges;k++){
printf(
"输入: ");
scanf(
"%d,%d,%d", &i,&j,&w);
G->arc[i][j]=w;
G->arc[j][i]=G->arc[i][j];
}
}
int main(
void)
{
MGraph G;
CreateMGraph(&G);
return 0;
}
转载请注明原文地址: https://ju.6miu.com/read-1297247.html