with recursive
  Pair(n1, n2, length, weight) 
  as (select n1, n2, 1, weight from Edge
      union
      select Pair.n1, Edge.n2, Pair.length+1, Pair.weight+Edge.weight
      from Pair, Edge
      where Pair.n2 = Edge.n1)
select * from Pair p1
where not exists (select * from Pair p2
                  where p2.weight > p1.weight);
