Browse Source

Add dag-shortest-paths.

master
Sergiu Ivanov 10 months ago
parent
commit
a961cbde4e
  1. 12
      graph.rkt

12
graph.rkt

@ -39,7 +39,7 @@
min-st-kruskal max-st-kruskal min-st-prim max-st-prim
bellman-ford dijkstra
bellman-ford dijkstra dag-shortest-paths
graphviz)
@ -201,6 +201,8 @@
(g:bellman-ford (gg g) source))
(define (dijkstra g source)
(g:dijkstra (gg g) source))
(define (dag-shortest-paths g source)
(g:dag-shortest-paths (gg g) source))
;; 10 Graphviz
(define (graphviz g #:output [output #f] #:colors [colors #f])
@ -298,6 +300,8 @@
(Mutable-HashTable Any Any)))]
[dijkstra (-> Graph Any (Values (Mutable-HashTable Any Number)
(Mutable-HashTable Any Any)))]
[dag-shortest-paths (-> Graph Any (Values (Mutable-HashTable Any Number)
(Mutable-HashTable Any Any)))]
;; 10 Graphviz
[graphviz (->* (Graph)
@ -435,6 +439,12 @@
(check-equal? (hash->ordered-list dj-dists)
'((a . 0) (b . 1) (c . 2) (d . 4)))
(check-equal? (hash->ordered-list dj-pred)
'((a . #f) (b . a) (c . a) (d . b)))
(define-values (dsp-dists dsp-pred) (dag-shortest-paths g0 'a))
(check-equal? (hash->ordered-list dsp-dists)
'((a . 0) (b . 1) (c . 2) (d . 4)))
(check-equal? (hash->ordered-list dsp-pred)
'((a . #f) (b . a) (c . a) (d . b))))
(test-case "10 Graphviz"

Loading…
Cancel
Save