Add min-st-prim and max-st-prim.

Sergiu Ivanov 2021-10-31 22:09:17 +01:00
parent 25671ff201
commit 2b7723dbad
1 changed files with 12 additions and 2 deletions

View File

@ -37,7 +37,7 @@
dfs dfs/generalized
dag? tsort cc cc/bfs scc
min-st-kruskal max-st-kruskal
min-st-kruskal max-st-kruskal min-st-prim max-st-prim
@ -189,6 +189,10 @@
(g:min-st-kruskal (gg g)))
(define (max-st-kruskal g)
(g:max-st-kruskal (gg g)))
(define (min-st-prim g source)
(g:min-st-prim (gg g) source))
(define (max-st-prim g source)
(g:max-st-prim (gg g) source))
;; 10 Graphviz
(define (graphviz g #:output [output #f] #:colors [colors #f])
@ -278,6 +282,8 @@
;; 5 Spanning Trees
[min-st-kruskal (-> Graph (Listof (List Any Any)))]
[max-st-kruskal (-> Graph (Listof (List Any Any)))]
[min-st-prim (-> Graph Any (Listof (List Any Any)))]
[max-st-prim (-> Graph Any (Listof (List Any Any)))]
;; 10 Graphviz
[graphviz (->* (Graph)
@ -396,7 +402,11 @@
(check-equal? (min-st-kruskal g0)
'((a e) (c d) (c b) (a b)))
(check-equal? (max-st-kruskal g0)
'((c b) (c a) (c d) (a e))))
'((c b) (c a) (c d) (a e)))
(check-equal? (min-st-prim g0 'e)
'((b c) (e a) (c d) (a b)))
(check-equal? (max-st-prim g0 'e)
'((a c) (e a) (c d) (c b))))
(test-case "10 Graphviz"
(define g (directed-graph '((a b) (b c))))