typedef char VertexType;
typedef struct ArcNode {
int adjvex;
struct ArcNode *nextarc;
} ArcNode;
typedef struct VNode {
VertexType data;
ArcNode *firstarc;
} VNode, AdjList[MAX_VERTEX_NUM];
typedef struct {
AdjList vertices;
int vexnum, arcnum;
} ALGraph;
Status DfsReachable(ALGraph g, int i, int j)
{ if( !g.vexnum || !g.arcnum ) return FALSE;
Queue Q;
InitQueue( Q );
EnQueue( Q, i );
int u;
while( ! QueueEmpty ( Q ) )
{
DeQueue( Q, u );
visited[u] = 1;
ArcNode *p;
int k;
for( p = g.vertices[u].firstarc; p; p = p->nextarc )
{
k = p->adjvex;
if( k == j ) return OK;
if( !visited[k] ) EnQueue( Q, k );
}
}
return FALSE;
}