Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created August 13, 2012 14:42
Show Gist options
  • Save swannodette/3341330 to your computer and use it in GitHub Desktop.
Save swannodette/3341330 to your computer and use it in GitHub Desktop.
clique.clj
(defrel connected ^:index x ^:index y)
(facts connected [[1 2] [1 5]])
(facts connected [[2 1] [2 3] [2 5]])
(facts connected [[3 2] [3 4]])
(facts connected [[4 3] [4 5] [4 6]])
(facts connected [[5 1] [5 2] [5 4]])
(facts connected [[6 4]])
(defne connected-to-allo
"Ensure that vertex v is connected to all vertices
vs."
[v vs]
([_ ()])
([_ [vh . vr]]
(connected v vh)
(connected-to-allo v vr)))
(defne all-connected-to-allo
"Collect all cliques in l. l must be bounded to ensure
termination."
[l]
([()])
([[h . t]]
(connected-to-allo h t)
(all-connected-to-allo t)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment