WITH e AS (
  -- find the coauthors of Erdös
  SELECT DISTINCT b.author, 1 AS depth
  FROM auth AS a
    -- same paper, but different author
    JOIN auth AS b ON a.dblp_key = b.dblp_key
                   AND a.author != b.author
  WHERE a.author = 'Paul Erdös'
)
  SELECT * FROM e
UNION
  -- find the coauthors of coauthors
  SELECT DISTINCT d.author, e.depth + 1 AS depth
  FROM e
    -- first get all papers of e's authors
    JOIN auth AS c ON e.author = c.author
    -- same paper, but different author
    JOIN auth AS d ON c.dblp_key = d.dblp_key
                   AND c.author != d.author
  WHERE d.author != 'Paul Erdös'
    AND d.author NOT IN (SELECT author FROM e)
ORDER BY author, depth;
