                   marked (if is-seg-c
                            (:node-edges right-sib)
                            (if (:is-seg-c right-sib)
-                             #{edge}
+                             #{(:forward-edge edge)}
                              #{}))
                   l (update-in layer [:marked] set/union marked)]
               (recur l tree parent-index c))



(defrecord Node [id layer-id characters])
(defrecord Edge [dest characters])
(defrecord Layer [id duration nodes marked])
(defrecord SegmentContainer [segments])
(defrecord Segment [edge])

  bi-layer ordering. Implements the algorithm found in Bilayer Cross Counting,
  by Wilhelm Barth, Petra Mutzel and Michael Jünger"
  [graph layer next-layer]
  (let [minus-p (:minus-ps layer)
        without-qs (:without-qs next-layer)
        [layer-1 layer-2 edges] (if (< minus-p without-qs)
                                  [without-qs minus-p (:preds graph)]
                                  [minus-p without-qs (:succs graph)])
        edge-order (sorted-edge-order layer-1 layer-2 edges)
        tree-size (next-power-of-2-minus-1 (count layer-2))
        first-leaf (/ (dec tree-size) 2)]
    (loop [layer layer
           tree (vec (repeat tree-size (AccumulatorNode. 0 #{} false)))
           crossings 0
           order edge-order]
      (if (empty? order)
        [layer crossings]
        (let [[ord edge] (first order)
