I am trying to model a graph using core.logic and would like to match all nodes that have edges to two other nodes. I have come up with the below but it returns two results instead of the desired one, as [2 3 4] and [2 4 3] are equivalent. How would I constrain the query to only return the desired result?
(use 'clojure.core.logic.pldb)
(db-rel edge a b)
(def g
(db
[edge 1 2]
[edge 2 3]
[edge 3 4]
[edge 2 4]))
(with-db g
(run* [q]
(fresh [x y z]
(edge x y)
(edge x z)
(!= y z)
(== q [x y z]))))