void deptht(graph g,int x)
{
//主要操作步骤
arcnode *p;
vis[x]=1;
cout<<g.adjlist[x].data;
p=g.adjlist[x].firstarc;
//主要递归步骤
while(p)
{
if(vis[p->adjvex]==0)
{
deptht(g,p->adjvex);
}
p=p->nexarc;
}
}
算法思想总结:开始的时候传入顶点,标记其已经被访问,将vis[x]置为1,然后遍历该点的邻点,(关键要知道边是边,顶点是顶点)。然后继续该顶点未被访问则递归执行,一直向下遍历。