#include#include #define Max 20 typedef struct Node { int num; struct Node *next; }Node; Node G[Max]; int visited[Max]; void Creategraph(int n,Node G[]) { int i,e,j; Node *p,*q; for(i=0;i >e; e=e-1; j=0; while(e!=-1&&j next=NULL; p->num=e; j++; if(G[i].next==NULL) G[i].next=p; else q->next=p; q=p; cout<<"請輸入第"<>e; e=e-1; } } } int First(Node G[],int v) { if(G[v].next!=NULL) return G[v].next->num; return -1; } int Next(Node G[],int v) { Node *p; p=G[v].next; while(p!=NULL) { if(visited[p->num]) p=p->next; else return p->num; } return -1; } void DFS(Node G[],int v) { int w; cout< >n; Creategraph(n,G); for(i=0;i