dijkstra fixed

svn: r152
This commit is contained in:
Jono Spiro 2004-08-06 17:50:11 +00:00
parent 46868034e1
commit 1f557bd171
5 changed files with 20 additions and 25 deletions

View File

@ -1,39 +1,39 @@
(require "dijkstra-solver.ss"
(lib "match.ss"))
(define-mztake-process p
(define-mztake-process p
("dijkstra.ss")
("heap.ss"
[inserts 49 6 bind 'item]
[removes 67 10 bind 'result]))
("heap.ss" [inserts 49 6 bind 'item]
[removes 67 10 bind 'result]))
(define (not-in-order e)
(filter-e
(match-lambda
[('reset _) false]
[(_ 'reset) false]
[(previous current) (> previous current)])
[(previous current) (> previous current)]
[else false])
(history-e 2 e)))
(history-e 5 (history-e 2 (merge-e (removes . ==> . node-weight)
(inserts . -=> . 'reset))))
(define violations
(not-in-order (merge-e (removes . ==> . node-weight)
(inserts . -=> . 'reset))))
(define inserts-and-removes-e (merge-e (removes . ==> . node-weight)
(inserts . -=> . 'reset)))
(define violations (not-in-order inserts-and-removes-e))
(printf-b "all inserts and removes: ~a" (history-b inserts-and-removes-e))
(printf-b "all violations: ~a" (history-b violations))
(printf-b "latest-violation: ~a" (hold violations))
(define latest-violation (hold violations))
(define ((insert-in-model item) model) (cons item model))
(define ((remove-from-model item) model) (filter (lambda (i) (eq? i item)) model))
(define inserters (inserts . ==> . insert-in-model))
(define removers (removes . ==> . remove-from-model))
(define inserters (accum-e (inserts . ==> . insert-in-model) empty))
(define removers (accum-e (removes . ==> . remove-from-model) empty))
(define model (accum-b (merge-e inserters removers) empty))
(define model (merge-e inserters removers))
(printf-b "latest-violation: ~a" latest-violation)
(printf-b "model: ~a" model)
(start/resume p)

View File

@ -33,8 +33,4 @@
;(pretty-print (graph-to-list g))
(printf "output:~n")
(print-struct #t)
(pretty-print (solve g (reverse nodes) (n-ref 's)))
)
(pretty-print (solve g (reverse nodes) (n-ref 's))))

View File

@ -1,4 +0,0 @@
Add this to the demos section of the main doc.
demos/djikstra/dijkstra-test.ss - debugs a buggy implementation of
Dijkstra's algorithm

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@ -159,6 +159,9 @@ MzTake without ever having written a FrTime script before!
can trace first-class functions, such
as those passed to map.
./djikstra/dijkstra-test.ss - debugs a buggy implementation of
Dijkstra's algorithm
============================================================