Hey ipsita check it out this code, is in java, mat is the adjacency matrix,
it has -1 for a node that can be connected directly.
public void paths(int sou,int dest,int mat[][],Vector stack)
{
    boolean band = true;
    if(sou == dest)
    {
       //path it is inside of stack, and dest
    }
    for(int i = 0; i < mat[0].length;i++)
    {
      if(mat[sou][i] != -1)
      {
         if(!visited(i,stack))//if doesn´t pass by this node
         {
             if(band) {stack.add(sou); band = false;}
             paths(i,dest,mat,stack);
         }
      }
    }
    stack.remove(stack.size()-1);//get out the last element on the path
already explored
    return;
}
public boolean visited(int i,Vector stack)
{
   boolean ret = false; int aux;
   for(int j = 0; j < stack.size();j++)
   {
      aux = Integer.parseInt(pila.elementAt(j).toString());
      if(i == aux) {ret = true; break;}
   }
   return ret;
}

On 4/6/07, ipsita <[EMAIL PROTECTED]> wrote:
>
>
> hi all !!!
> plz give an algorithm for finding all the simple paths in a graph.
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to