0

I can get all paths by using DFS if the graph like this:

enter image description here The path is D-C-B-A and D-E-A But the progame go into a loop if the grapg like this:

enter image description here

I need some examples or pseudocode to deal with grapg which has circles.

If anyone needs the source code of DFS in plsql programming language(It is not beautiful),please leave a message.

Thanks!

lxf
  • 51
  • 2

1 Answers1

0

I have solved the problem。 Here is the pseudocode

function dfs(start_obj,end_obj,stack,d)
{
  d=d+1;
 stack.push(start_obj);
  visited(start_obj)=true;
  if (start_obj==end_obj){
       #print the path in stack     
       }

  p:=get_first_starc(start_obj); #get the first vertex
  while(p){
  w=p;
  if (visited(start_obj))
    { 
      dfs(start_obj,end_obj,stack,d)
      }
  p=get_next_starc(start_obj)

  }
stack.pop();
 

}
lxf
  • 51
  • 2