chickadee » aima » connect!

connect! world connectend connector directionprocedure

Bi-connect two locations over a direction and its inverse.

world
The graph-world within which to connect
connectend
The node to be connected
connector
The connecting node
direction
The relative direction to connect over
(define (connect! world connectend connector direction)
  (hash-table-update!/default
    world
    connectend
    (lambda (location)
      (vector-set! (location-neighbors location) direction connector)
      location)
    (make-dirty-location))
  (hash-table-update!/default
    world
    connector
    (lambda (location)
      (vector-set!
        (location-neighbors location)
        (reverse-direction direction)
        connectend)
      location)
    (make-dirty-location)))