Dev Helpers
← Back

Avoid revisiting graph nodes

Avoid revisiting graph nodes using SQLite.

Open this example in the interactive library

Source code

WITH RECURSIVE edges(p,c) AS (VALUES(1,2),(2,1)), walk(n) AS (VALUES(1) UNION SELECT c FROM edges JOIN walk ON p=n) SELECT n FROM walk;

Sample output

[
  {
    "n": 1
  },
  {
    "n": 2
  }
]