3 Replies Latest reply: Jul 17, 2012 11:09 PM by 890463 RSS

    All Paths between 2 Nodes

    890463
      Hi ,

      Can someone please let me know how I could be achieving this?

      I want to find out all the paths between the Source Node A and the Destination Node B.

      I donot want the shortest path but all the paths between the 2 nodes.

      Also I donot have any weight/cost associated with any path. ( Graph is a directed graph)

      Regards,
      Akshatha
        • 1. Re: All Paths between 2 Nodes
          Galbarad
          try this
          http://docs.oracle.com/cd/B19306_01/server.102/b14200/queries003.htm

          or type in google "oracle hierarchical query"

          and also you must provide input data for fast and correct answers

          good luck
          • 2. Re: All Paths between 2 Nodes
            Nicosa-Oracle
            Hi,

            Maybe this :
            Scott@my11g SQL>l
              1  with links(n1,n2) as (
              2  select 'A','B' from dual
              3  union all select 'A','C' from dual
              4  union all select 'B','C' from dual
              5  union all select 'B','D' from dual
              6  union all select 'D','G' from dual
              7  union all select 'C','G' from dual
              8  union all select 'D','I' from dual
              9  union all select 'C','E' from dual
             10  union all select 'E','F' from dual
             11  union all select 'F','G' from dual
             12  union all select 'F','H' from dual
             13  )
             14  select pth
             15  from (
             16  select connect_by_root(n1) || sys_connect_by_path(n2,'>') pth ,n2
             17  from links
             18  start with n1='A'
             19  connect by nocycle prior n2=n1
             20  )
             21* where n2='G'
            Scott@my11g SQL>/
            
            PTH
            ----------------------------------------
            A>B>C>E>F>G
            A>B>C>G
            A>B>D>G
            A>C>E>F>G
            A>C>G
            • 3. Re: All Paths between 2 Nodes
              890463
              Thanks a lot :) It worked!