typedef struct MatrixGraph* PtrToMatrixGraph;
struct MatrixGraph {
int VertexNum=0;//顶点数
int EdgeNum=0;//边数
VertexType VertexData[MaxVertexNum];//顶点数据(数组)
EdgeWeightType EdgeWeight[MaxVertexNum][MaxVertexNum];//边权重(数组)
};
typedef PtrToMatrixGraph MGraph;
MGraph CreatZeroEdgeGraph(int VertexNum) {
MGraph Graph;
int i,j;
Graph->EdgeNum = 0;//此处报错:使用了未初始化的局部变量
Graph->VertexNum = VertexNum;
原因:没有为其分配地址Graph = (MGraph)malloc(sizeof(struct MatrixGraph ));