From 15681c23aeec006b0122f0e6da16f8c3b3e0516b Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Fri, 1 Jan 2021 21:31:14 +0100 Subject: [PATCH] Add has-vertex?. --- graph.rkt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/graph.rkt b/graph.rkt index a7d6613..2d45323 100644 --- a/graph.rkt +++ b/graph.rkt @@ -22,6 +22,7 @@ (require (prefix-in g: graph)) (provide graph? directed-graph + has-vertex? has-edge? graphviz) @@ -29,6 +30,8 @@ (define (directed-graph es [ws #f]) (graph (g:directed-graph es ws))) + (define (has-vertex? g v) + (g:has-vertex? (graph-g g) v)) (define (has-edge? g u v) (g:has-edge? (graph-g g) u v)) (define (graphviz g #:output [output #f] #:colors [colors #f]) @@ -37,6 +40,7 @@ (require/typed 'graph-wrapper [#:opaque Graph graph?] [directed-graph (->* ((Listof (List Any Any))) ((Listof Any)) Graph)] + [has-vertex? (-> Graph Any Boolean)] [has-edge? (-> Graph Any Any Boolean)] [graphviz (->* (Graph) (#:output Output-Port @@ -45,4 +49,5 @@ (define g (directed-graph '((a b) (b c)))) (has-edge? g 'a 'c) +(has-vertex? g 'a) (graphviz g)