From df1ef5b6936efa4f4f8555556bf7d662ce17186d Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Sat, 16 Jul 2011 13:49:46 -0400 Subject: [PATCH] union find fixing --- union-find.rkt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/union-find.rkt b/union-find.rkt index 0e4c447..f5923c3 100644 --- a/union-find.rkt +++ b/union-find.rkt @@ -31,7 +31,11 @@ ;; Returns the node that's associated with this element. (: lookup-node (forest Symbol -> node)) (define (lookup-node a-forest an-elt) - (hash-ref (forest-ht a-forest) an-elt)) + (unless (hash-has-key? (forest-ht a-forest) an-elt) + (make-set a-forest an-elt)) + (hash-ref (forest-ht a-forest) + an-elt)) + ;; make-set: forest X -> void