fix visited
This commit is contained in:
parent
fc14f5ee76
commit
d727e41a07
|
@ -26,8 +26,10 @@
|
||||||
#:init (or (and (item? $v) (set-member? held (item-name $v)))
|
#:init (or (and (item? $v) (set-member? held (item-name $v)))
|
||||||
(conj? $v)
|
(conj? $v)
|
||||||
(and (requirement? $v) (empty? (get-neighbors G $v)))))
|
(and (requirement? $v) (empty? (get-neighbors G $v)))))
|
||||||
|
(define-vertex-property G visited? #:init #f)
|
||||||
(do-dfs G
|
(do-dfs G
|
||||||
#:visit?: #t
|
#:prologue: (visited?-set! $to #t)
|
||||||
|
#:visit?: (not (visited? $to))
|
||||||
#:epilogue: (cond
|
#:epilogue: (cond
|
||||||
[(and (conj? $from) (not (attainable? $to)))
|
[(and (conj? $from) (not (attainable? $to)))
|
||||||
(attainable?-set! $from #f)]
|
(attainable?-set! $from #f)]
|
||||||
|
@ -39,6 +41,7 @@
|
||||||
(define requirements
|
(define requirements
|
||||||
(hash "a" (list (list "apples" "bananas" "meows") (list "bananas") (list "c"))
|
(hash "a" (list (list "apples" "bananas" "meows") (list "bananas") (list "c"))
|
||||||
"b" '()
|
"b" '()
|
||||||
|
"d" (list (list "apples" "d"))
|
||||||
"c" (list (list "apples" "meows"))))
|
"c" (list (list "apples" "meows"))))
|
||||||
(define held (set "apples" "bananas" "clementines"))
|
(define held (set "apples" "bananas" "clementines"))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue