求解请大家一个程序中NULL的有关问题,程序有点长,麻烦大家耐心看一下

求解请大家一个程序中NULL的问题,程序有点长,麻烦大家耐心看一下
header.h
#include<iostream>
using namespace std;
const int MaxVertexNum=20;
struct EdgeNode{
int adjvex;
struct EdgeNode * next;
};
struct VNode{
int data;
EdgeNode * firstedge;
};
class ALGraph{
public:
ALGraph();
~ALGraph();
int LocateVex(int u);
ALGraph & InsertVex(int v);
ALGraph & DeleteVex(int v);
ALGraph & InsertArc(int v,int w);
ALGraph & DeleteArc(int v,int w);
void DisPlay();
VNode vertices[MaxVertexNum];
private:
int vexnum;
int arcnum;
};

header.cpp
#include"header.h"
int ALGraph::LocateVex(int u)
{
for(int i=0;i<vexnum;i++)
if(vertices[i].data==u)
return i;
return -1;
}
ALGraph::ALGraph()
{
int i,j,k;
int v1,v2;
cout<<"请输入图的顶点数,边数:";
cin>>vexnum>>arcnum;
cout<<"请输入"<<vexnum<<"个顶点的值:";
for(i=0;i<vexnum;i++)
{
cin>>vertices[i].data;
vertices[i].firstedge==NULL;
}
for(k=0;k<arcnum;k++)
{
cout<<"请输入一条弧的弧尾、弧头:";
cin>>v1>>v2;
i=LocateVex(v1);
j=LocateVex(v2);
EdgeNode * p=new EdgeNode;
p->adjvex=j;
p->next=vertices[i].firstedge;
vertices[i].firstedge=p;
}
}
ALGraph & ALGraph::InsertVex(int u)
{
if(vexnum>MaxVertexNum)
{
cout<<"顶点数超出范围,无法插入!";
exit(1);
}
if(LocateVex(u)>=0)
{
cout<<"顶点已存在";
exit(1);
}
vertices[vexnum].data=u;
vertices[vexnum].firstedge=NULL;
vexnum++;
return *this;
}
ALGraph & ALGraph::DeleteVex(int v)
{
int i,j;
EdgeNode * p,* q;
i=LocateVex(v);
p=vertices[i].firstedge;
while(p)
{
q=p;
p=p->next;
delete q;
arcnum--;
}
vexnum--;
for(j=i;j<vexnum;j++)
vertices[j]=vertices[j+1];
for(j=0;j<vexnum;j++)
{
p=vertices[j].firstedge;
while(p)
{
if(p->adjvex==i)
{
if(p==vertices[j].firstedge)
{
vertices[j].firstedge=p->next;
delete p;
p=vertices[j].firstedge;
arcnum--;
}
else
{
q->next=p->next;
delete p;
p=q->next;
arcnum--;
}
}
else
{
if(p->adjvex>i)//由于节点少了一个,故对于》i的节点采取了--的操作。