#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define MAX_VERTEX_NUM 20
#define OVERFLOW -2
#define OK 1
typedef int Status;
typedef char VertexType[MAX_VERTEX_NUM];
typedef char InfoType;
//弧(边)的结构体
typedef struct ArcBox
{
int tailvex, headvex; //该弧的尾和头顶点的位置
struct ArcBox *hlink, *tlink; //分别为弧头相同和弧尾相同的弧的链域
InfoType *info; //该弧的相关信息的指针
}ArcBox;
//顶点的结构体
typedef struct VexNode
{
VertexType data;
ArcBox *firstin, *firstout; //分别指向该顶点的第一条入弧和出弧
}VexNode;
//有向图的结构体
typedef struct
{
VexNode xlist[MAX_VERTEX_NUM]; //表头向量
int vexnum, arcnum; //有向图的当前顶点数和弧数
}OLGraph;
int LocateVex(OLGraph &G, VertexType u)
{
for (int i = 0; i < G.vexnum; ++i)
if (strcmp(G.xlist[i].data, u) == 0)
return i;
return -1;
}
//构造有向图G;
Status CreateDG(OLGraph &G)
{
int i, j, k;
int x = 0;
int y = 0;
G.vexnum = 7115;
G.arcnum = 103689;
string buffer;
char str1;
char str2;
char str3;
stringstream ss;
ifstream inputFile("C:\\Users\\liux\\Desktop\\nodes.txt");
while (getline(inputFile, buffer)) {
for (i = x; i < G.vexnum;) //构造表头向量
{
ss.clear();
ss.str(buffer);
ss >> str1;
G.xlist[i].data = str1; //出错,表达式必须是可修改的左值
G.xlist[i].firstin = NULL;
G.xlist[i].firstout = NULL;
break;
}
x++;