Changeset 29450 in project
 Timestamp:
 07/29/13 14:43:22 (6 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

wiki/eggref/4/aima
r29395 r29450 157 157 * [[#cspdomains]] 158 158 * [[#cspneighbors]] 159 * [[#failure]] 159 160 * [[#failure?]] 160 161 * [[#inference]] 161 162 * [[#makecsp]] 162 163 * [[#neq?]] 164 * [[#randommap]] 165 * [[#setalldiffconstraints!]] 166 * [[#setbidirectionalconstraint!]] 167 * [[#setpairwisebidirectionalconstraints!]] 168 * [[#setpairwiseconstraints!]] 169 * [[#setdomains!]] 163 170 * [[#success?]] 164 171 * [[#xor]] … … 266 273 ; y : Comparator 267 274 <enscript highlight="scheme">(define neq? (complement eq?)) 275 </enscript> 276 ==== {{randommap}} 277 <procedure>(randommap n) â hashtable</procedure> 278 Create a random kcoloring problem; returns an adjacencylist of 279 nodes as a hashtable. 280 ; n : The number of nodes in the problem 281 <enscript highlight="scheme">(define (randommap n) 282 (let ((randompoints (randompoints n)) (connections (makehashtable))) 283 (let iterpoint ((points randompoints) (modified? #f)) 284 (if (null? points) 285 (if modified? (iterpoint (shuffle randompoints) #f) connections) 286 (let ((point (car points))) 287 (let itercounterpoint ((counterpoints 288 (sortbyproximity 289 point 290 (delete point randompoints)))) 291 (if (null? counterpoints) 292 (iterpoint (cdr points) modified?) 293 (let ((counterpoint (car counterpoints))) 294 (if (member 295 point 296 (hashtableref/default connections counterpoint '())) 297 (itercounterpoint (cdr counterpoints)) 298 (if (intersectsother? connections point counterpoint) 299 (itercounterpoint (cdr counterpoints)) 300 (begin 301 (hashtableupdate!/default 302 connections 303 point 304 (lambda (counterpoints) 305 (lsetadjoin eq? counterpoints counterpoint)) 306 '()) 307 (hashtableupdate!/default 308 connections 309 counterpoint 310 (lambda (points) (lsetadjoin eq? points point)) 311 '()) 312 (iterpoint (cdr points) #t)))))))))))) 268 313 </enscript> 269 314 === AIMATessellation
Note: See TracChangeset
for help on using the changeset viewer.