      [^Vertex o ^java.io.Writer w] (.write w (.toString (into {} o)))))
 
 (defn vertex
-  [id val state]
+  [id val opts]
   (map->Vertex
    {:id       id
     :value    (atom val)
-    :state    (atom (merge default-vertex-state state))
+    :state    (atom (merge default-vertex-state opts))
     :prev-val (atom nil)
     :in       (atom nil)
     :outs     (atom {})}))

    [_] ((::score-collect-fn @state) _))
  (connect-to!
    [_ v sig-fn opts]
    (debug id "connecting to" (:id v) "(" (pr-str opts) ")")
    (swap! outs assoc v [sig-fn opts]) _)
  (connected-vertices
    [_] (keys @outs))
  (disconnect-vertex!
    [_ v]
    (debug id "disconnecting from" (:id v))
    (swap! outs dissoc v)
    _)
  (disconnect-all!

  [vertex]
  (if (= @vertex @(:prev-val vertex)) 0 1))

(defn score-signal-with-new-edges
  "Computes vertex signal score. Returns number of *new* outgoing
  edges plus 1 if value not equals prev-val. New edge counter is reset
  each time signal! is called."
  [vertex]
  (+ (::new-edges @(:state vertex)) (if (= @vertex @(:prev-val vertex)) 0 1)))

(defn default-score-collect
  "Computes vertex collect score, here simply the number
  of ::uncollected signal values."
