 
 
 (defn- set-positions
-  "Positions in an alternating layer are used to calculate the order of the next layer.
+  "Positions in an ordered layer are used to calculate the order of the next layer.
   ESK's description of the position algorithm is almost willfully circuitous and obtuse,
-  so here's a simplified description: An item's position in an alternating layer is the
+  so here's a simplified description: An item's position in an ordered layer is the
   sum of the size of all previous items, plus 1, where the size of a segment container
   is the number of segments it contains, and the size of a node is 1.
 
   Also, it doesn't really matter what seed you choose for the initial value of the sum. I
   chose -1, which is implied by the description in ESK."
   [layer]
-  (loop [alt (:alternating layer)
+  (loop [ordered (:ordered layer)
          current-position -1
          positions {}]
-    (if (empty? alt)
+    (if (empty? ordered)
       (assoc layer :positions positions)
-      (let [item (first alt)
-            ;; When (count alt) is odd, item is a SegmentContainer
-            c-p (if (odd? (count alt))
+      (let [item (first ordered)
+            c-p (if (instance? SegmentContainer item)
                   (+ current-position (count (:segments item)))
                   (inc current-position))]
-        (recur (rest alt) c-p (assoc positions item (inc current-position)))))))
+        (recur (rest ordered) c-p (assoc positions item (inc current-position)))))))
 
 
 (defn- set-qs-non-qs

                            (set-qs-non-qs graph)
                            (set-measures graph layer)
                            (order-next-layer layer)
                            add-qs
                            ensure-alternating)
            [marked-graph crossings] (count-crossings graph layer next-layer)
            g (-> marked-graph
                  (update-in [:crossings] + crossings)

  'An Efficient Implementation of Sugiyama’s Algorithm for Layered Graph Drawing',
  a paper by Markus Eiglsperger, Martin Sieberhaller, and Michael Kaufmann (ESK)"
  [sparse-graph]
  ;; seed the first layer with initial ordered layer
  (loop [seed-order (-> sparse-graph :layers first :nodes)
         orderings []]
    (let [c (count orderings)]
      (if (= c 20)
