                       (conj result [b (branches->nodes c causal-order heads)])))))))
 
 (defn nodes->order
-  "doc-string"
+  "Calculate commit order in time"
   [{:keys [nodes causal-order branches] :as cg}]
   (let [new-nodes (map
                    (fn [[b b-nodes]]

      (->> new-nodes
           (map (fn [[k v]] [k (rest v)]))
           (into {}))
      :branch-points
      (->> new-nodes
           (map (fn [[k v]] [k (first v)]))
           (into {})))))


(defn find-merge-points [{:keys [causal-order branches] :as cg}]
  (let [branch-heads (into {} (map (fn [[k v]] [v k]) branches))]
    (assoc cg
      :merge-points
      (->> causal-order
           (filter-map [key val] (> (count val) 1))
           (into {})
           (map (fn [[k v]] (map (fn [b] [b k]) (remove nil? (map branch-heads v)))))
           (apply concat)
           (into {})))))


(comment

                "dev" 120
                "fix-2" 140}})

  (->> test-cg
       commit-graph->nodes
       distinct-nodes
       nodes->order
       find-merge-links)

  )
