chickadee » aima » make-linear-world

make-linear-worldprocedure
make-linear-world n-nodesprocedure

Make a world that consists of a line of nodes (for testing pathological cases.

n-nodes
Number of nodes in the graph (default: (default-n-nodes))
(define make-linear-world
  (case-lambda
    (() (make-linear-world (default-n-nodes)))
    ((n-nodes)
     (let ((world (make-graph))
           (nodes (list-tabulate n-nodes (lambda i (make-node)))))
       (for-each
         (lambda (node1 node2) (connect! world node1 node2 right))
         (drop nodes 1)
         (drop-right nodes 1))
       world))))