#define VertexType int
#define AdjMatrix int
typedef enum{NG, DG, NW, DW}GraphKind;
#define Status int
#define MAX_N 10
#define OK 1
#define ERROR 0
typedef struct{
VertexType vexs[MAX_N];//表示顶点的数组;
AdjMatrix arcs[MAX_N][MAX_N];//表示边的二维数组;
int vexnum,arcnum;//顶点和边的个数;
GraphKind kind;
}MGraph;//定义图MGraph;用邻接矩阵表示。
#include<iostream>
#include<fstream>
#include"temp1.h"
using namespace std;
int LocateVex(MGraph G, VertexType v){
//在图G的vexs(顶点)中找值为v的元素的下标,如果没有则返回-1;
for(int i = 0; i < G.vexnum; i++){
if(G.vexs[i] == v){
return i;
}
}
return -1;
}
Status CreateMGraph(MGraph &G){
//创建图G,输入(读文件)的值有
//1.图的顶点数,边/弧的数目,图的类型
//2.依次输入顶点的值
//3.依次输入一条边的起点和终点;
ifstream in;
in.open("data3.txt", ios::in);
cout<<"下列数据从文件data3.txt读入"<<endl<<endl;
cout<<"请输入图的顶点数,边/弧的数目,图的类型"<<endl;
int kind;