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