A typed interface to the Racket generic graph library.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

32 lines
940 B

#lang typed/racket
;https://stackoverflow.com/questions/65386334/racket-generic-graph-library-in-typed-racket
(module graph-wrapper racket
(require (prefix-in g: graph))
(provide graph?
directed-graph
has-edge?
graphviz)
(struct graph (g))
(define (directed-graph es [ws #f])
(graph (g:directed-graph es ws)))
(define (has-edge? g u v)
(g:has-edge? (graph-g g) u v))
(define (graphviz g #:output [output #f] #:colors [colors #f])
(g:graphviz (graph-g g) #:output output #:colors colors)))
(require/typed 'graph-wrapper
[#:opaque Graph graph?]
[directed-graph (->* ((Listof (List Any Any))) ((Listof Any)) Graph)]
[has-edge? (-> Graph Any Any Boolean)]
[graphviz (->* (Graph)
(#:output Output-Port
#:colors (HashTable Any Natural))
String)])
(define g (directed-graph '((a b) (b c))))
(has-edge? g 'a 'c)
(graphviz g)