 
 
 
-(defn make-new-edge [from to world-state]
-  (let [next-to-largest-key (next-key (largest-key world-state))]
-    [next-to-largest-key [from to :red]]))
+(defn make-new-edge [from to {:keys [edges]}]
+  (let [new-key (next-key edge-id edges)]
+    [new-key [from to :red]]))
 
 
 

  (:require [constraint.common :refer [edge-id
                                       vert-id]]))

(def edge-id-len (count edge-id))
(def vertex-regex (re-pattern (str vert-id ".*")))
(def edge-regex (re-pattern (str edge-id ".*")))





(defn get-key [len edge-str]
  (->> edge-str
       (drop len)
       (apply str)
       (js/parseInt)))



(defn largest-key [id coll]
  (let [get-number-part (partial get-key (count id))]
    (-> (map get-number-part (keys coll))
        (sort)
        (reverse)
        (first))))



(defn inc-key [id key-num]
  (str id (inc key-num)))



(defn next-key [id coll]
  (inc-key id (largest-key id coll)))




