with recursive
  Pair(n1, n2) as (select n1, n2 from Edge
                   where n1 in (select nID from Node
                                where color = 'yellow')
                     and n2 in (select nID from Node
                                where color = 'blue')
                   union
                   select Pair.n1, Edge.n2
                   from Pair, Edge
                   where Pair.n2 = Edge.n1
                     and ((Pair.n2 in (select nID from Node
                                      where color = 'yellow')
                          and
                          Edge.n2 in (select nID from Node
                                      where color = 'blue'))
                       or (Pair.n2 in (select nID from Node
                                       where color = 'blue')
                           and
                           Edge.n2 in (select nID from Node
                                       where color = 'yellow'))))
select n1, n2 from Pair
order by n1, n2;
