 
 (defn strut-position [config columns tx ty]
   (- (first (arrow-end config tx ty)) (strut-offset config columns tx ty)))
+
+(defn has-far-arrows? [graph columns node]
+  (zero? (g/out-degree (g/subgraph graph (conj (apply concat (rest columns)) node))
+                       node)))
+
+(defn build-columns [{:keys [graph remaining-ranks columns]}]
+  (if (empty? remaining-ranks)
+    columns
+    (let [{far-arrows false no-far-arrows true}
+          (group-by #(has-far-arrows? graph columns %) (first remaining-ranks))
+          next-column
+          (if far-arrows
+            (let [height-to-clear (->> (conj columns no-far-arrows) (map count) (apply max))
+                  padding (- height-to-clear (count no-far-arrows))]
+              (concat no-far-arrows (take padding (repeat nil)) far-arrows))
+            no-far-arrows)]
+      (recur
+       {:graph graph
+        :remaining-ranks (rest remaining-ranks)
+        :columns (conj columns next-column)}))))
 
 (defn map-layout [{:keys [box-width box-height arrow-radius] :as config} columns edges]
   (let [coords (into {}

        :height box-height
        :content thing})}))

(defn map-svg [{:keys [box-width box-height arrow-radius] :as config} columns edges]
  (let [{:keys [arrows boxes]} (map-layout config columns edges)]
    (html
     [:div {:style {:background "white"}}
      [:svg {:width "2000"


  (defcard map
    (let [g (transitive-reduction frontend-graph)
          config {:box-width 150
                  :box-height 40
                  :x-spacing 100
                  :y-spacing 10
                  :strut-spacing 20
                  :arrow-radius 10}]
      (map-svg config g)))

  (defcard arrow
    (html
