 
   (.get-or-create-index kn "know" "heights" #js ["height" "name"])
 
+  (.get-or-create-index kn "know" "edge" #js ["x" "y"])
+
+  (.get-or-create-index kn "know" "connected" #js ["x" "y"])
+
+  (.add-facts kn "know" "edge" #js ["x" "y"] #js [#js ["a" "b"] #js ["b" "c"] #js ["c" "d"] #js ["d" "b"]])
+
+  (def edge-flow
+    (Join. #js ["magic_iterator"] #js [#js [(.get-or-create-index kn "know" "edge" #js ["x" "y"]) #js [0 1]]]
+           #js ["know"] #js ["connected"] #js [#js ["x" "y"]]))
+
+  (def connected-flow
+    (Join. #js ["magic_iterator" "magic_iterator"] #js [#js [(.get-or-create-index kn "know" "edge" #js ["x" "y"]) #js [0 1 nil]]
+                                                        #js [(.get-or-create-index kn "know" "connected" #js ["x" "y"]) #js [nil 0 1]]]
+           #js ["know"] #js ["connected"] #js [#js ["x" nil "y"]]))
+
+  (def transitive-flow
+    (Chain. #js [edge-flow (Fixpoint. connected-flow)]))
+
+  (.run transitive-flow kn)
+
+  (.get-or-create-index kn "know" "connected" #js ["x" "y"])
   )

(ns aurora.language
  (:require [aurora.btree :as btree])
  (:require-macros [aurora.macros :refer [apush set!!]]))

(defn keymap [from-fields to-fields]
  (let [keymap (make-array (alength to-fields))]

    keymap))

(defn with-keymap [keymap key]
  (let [new-key (make-array (alength keymap))]
    (dotimes [i (alength keymap)]
      (aset new-key i (aget key (aget keymap i))))
    new-key))
