         swapd [ [ rot ] dip at delete-at drop ] 2curry assoc-each
     ] if-graph ; inline
 
+<PRIVATE
+
 : (closure) ( obj assoc quot: ( elt -- assoc ) -- )
     2over key? [
         3drop

! See http://factorcode.org/license.txt for BSD license.
USING: assocs kernel namespaces sequences sets ;
IN: graphs

: if-graph ( vertex edges graph quot -- )
    dupd [ 3drop ] if ; inline

: nest ( key graph -- hash )
    [ drop H{ } clone ] cache ; inline

: add-vertex ( vertex edges graph -- )
    [ [ nest dupd set-at ] curry with each ] if-graph ; inline

        [ [ drop ] 3dip (closure) ] 2curry assoc-each
    ] if ; inline recursive

PRIVATE>

: closure ( obj quot -- assoc )
    H{ } clone [ swap (closure) ] keep ; inline
