Add min-st-kruskal.
This commit is contained in:
parent
f918eca123
commit
40059d1b75
1 changed files with 16 additions and 0 deletions
16
graph.rkt
16
graph.rkt
|
@ -37,6 +37,8 @@
|
|||
dfs dfs/generalized
|
||||
dag? tsort cc cc/bfs scc
|
||||
|
||||
min-st-kruskal
|
||||
|
||||
graphviz)
|
||||
|
||||
;; Wrap the opaque graph structure coming from the generic
|
||||
|
@ -182,6 +184,10 @@
|
|||
(define (scc g)
|
||||
(g:scc (gg g)))
|
||||
|
||||
;; 5 Spanning Trees
|
||||
(define (min-st-kruskal g)
|
||||
(g:min-st-kruskal (gg g)))
|
||||
|
||||
;; 10 Graphviz
|
||||
(define (graphviz g #:output [output #f] #:colors [colors #f])
|
||||
(g:graphviz (gg g) #:output output #:colors colors)))
|
||||
|
@ -267,6 +273,9 @@
|
|||
[cc/bfs (-> Graph (Listof (Listof Any)))]
|
||||
[scc (-> Graph (Listof (Listof Any)))]
|
||||
|
||||
;; 5 Spanning Trees
|
||||
[min-st-kruskal (-> Graph (Listof (List Any Any)))]
|
||||
|
||||
;; 10 Graphviz
|
||||
[graphviz (->* (Graph)
|
||||
(#:output Output-Port
|
||||
|
@ -377,6 +386,13 @@
|
|||
(check-equal? (scc (directed-graph '((a b) (b c) (c a) (c d) (e a))))
|
||||
'((e) (c b a) (d))))
|
||||
|
||||
;; 5 Spanning Trees
|
||||
(test-case "5 Spanning Trees"
|
||||
(define g0 (weighted-graph/undirected '((1 a b) (2 b c) (3 c a) (4 c d) (5 e a))))
|
||||
|
||||
(check-equal? (min-st-kruskal g0)
|
||||
'((a e) (c d) (c b) (a b))))
|
||||
|
||||
(test-case "10 Graphviz"
|
||||
(define g (directed-graph '((a b) (b c))))
|
||||
(check-equal? (graphviz g)
|
||||
|
|
Loading…
Reference in a new issue