思想:
Node path[MAX_LEN]; //MAX_LEN 取节点总数即可
int depth;
bool Dfs(V) {
if( V 为终点){
path[depth] = V;
return true;
}
if( V 为旧点)
return false;
将V 标记为旧点;
path[depth]=V;
++depth;
对和V 相邻的每个节点U {
if( Dfs(U) == true)
return true;
}
--depth;
return false;
}
int main()
{
将所有点都标记为新点;
depth = 0;
if( Dfs( 起点)) {
for(int i = 0;i <= depth; ++ i)
cout << path[i] << endl;
}
}
Node节点怎么写啊???
Finit
相关分类