                0)))
 
 
-(defn count-and-mark-crossings
+(defn count-and-mark-crossings-layer
   "Step 5 of ESK, counts the number of crossings that result from a bi-layer
   ordering. Implements the algorithm found in Bilayer Cross Counting, by
   Wilhelm Barth, Petra Mutzel and Michael Jünger

                                     (-> ordered-layer :items flatten)))))


(defn CountedAndMarkedGraph->FlatGraph
  "Transforms each OrderedLayer into a FlatLayer, and calculates attributes
  that are useful for organizing Nodes and Segments into horizontally-aligned
  blocks"
  [cm-graph]
  (let [{:keys [layers succs preds marked crossings characters]} cm-graph
        cm-layers (mapv OrderedLayer->FlatLayer layers)
        [aboves belows] (apply map merge (map neighborify cm-layers))
        [top-idxs bot-idxs] (apply map merge (map indexify cm-layers))]
    (map->FlatGraph {:layers cm-layers
                     :succs succs
                     :preds preds
                     :aboves aboves

                     :characters characters})))


(def SparseGraph->FlatGraph (comp OrderedGraph->FlatGraph
                                  best-ordering
                                  SparseGraph->ordered-graphs))
