帮我看一下,怎么顺序不对----邻接表的深度遍历
#define NULL 0
#define Max 20
#define TRUE 1
int visited[Max];
typedef struct ArcNode{
int adjvex;
struct ArcNode *nextarc;
int *info;
}ArcNode;
typedef struct {
int data;
ArcNode *firstarc;
}VNode;
typedef VNode AdjList[20];
typedef struct{
AdjList vertices;
int vexnum,arcnum;
int kind;
}ALGraph;
Creat(VNode *AdjList)
{
int m,n,j,i,s;ArcNode *p;
printf("please input the number of the ArcNode\n");
scanf("%d",&m);
printf("\n");
printf("please input the AdjList data\n");
for(i=1;i<=m;i++)
{
scanf("%d",&AdjList[i].data);
AdjList[i].firstarc=NULL;
AdjList[i].firstarc->nextarc=NULL;
}
for(i=1;i<=m;i++)
{
printf("please input the number linked with %d\n",AdjList[i].data);
scanf("%d",&n);
printf("please input the position connect with %d\n",AdjList[i].data);
for(j=1;j<=n;j++)
{
scanf("%d",&s);
p=(ArcNode *)malloc(sizeof(ArcNode));
p->adjvex=s;
p->nextarc=AdjList[i].firstarc->nextarc;
AdjList[i].firstarc->nextarc=p;
AdjList[i].firstarc=AdjList[i].firstarc->nextarc;
}
}
return m;
}
DFSTraverse(VNode *AdjList,int m)
{
int v;
for(v=1;v<=m;++v) visited[v]=NULL;
for(v=1;v<=m;++v)
if(!visited[v]) DFS(AdjList,v);
}
DFS(VNode *AdjList,int v)
{
/* int w;
visited[v]=TRUE;
printf("%d ",AdjList[v].data);
for(w=AdjList[v].firstarc->adjvex; w>=0; w=AdjList[v].firstarc->nextarc->adjvex)
if(!visited[w]) DFS(AdjList,w); */
ArcNode *p;
visited[v]=TRUE;
printf("%d ",AdjList[v].data);
p=AdjList[v].firstarc;
while(p!=NULL)
{ if(visited[p->adjvex]==0)
DFS(AdjList,p->adjvex);
p=p->nextarc;
}
}
main()
{
int n,v;VNode b;
n=Creat(&b);
DFSTraverse(&b,n);
}