Question: find the longest simple path from s to t in a directed graph. To determine the longest simple path in a directed graph is Np-complete, so the basic idea of solving this kind of problem is to use Exhaustive search. //graph[SIZE] is a linked-list representation of a directed graph, in which every element is graph[i] is //a neighbour of i; list graph[SIZE]; //weight[SIZE][SIZE] is a matrix representation, storeing the distance from i to j in weight[i][j]; //s is source, t is destination; int s, t; //longestDistance is a static varible to keep track of the longest distance from s to t; int longestDistance=0; //color[i] is used to mark whether i is visited or not; bool color[SIZE]={false}; color[s]=true; Exhaustive_search(s, 0); void Exhaustive_search(int node, int distance){ list::iterator iter; int neibour; for(iter=graph[node].begin(); iter!=graph[node].end(); iter++){ neighbout=*iter; if(color[neighbour]==false){ color[neighbour]=true; if(neighbour==t){ if(longestDistance