Add the BFS-related functions.

This commit is contained in:
Sergiu Ivanov 2022-01-02 00:26:43 +01:00
parent baf423f6e8
commit 324b47cb61
1 changed files with 23 additions and 1 deletions

View File

@ -2,10 +2,11 @@
@(require (for-label (only-in typed/racket
require/typed require/typed/provide
Any Boolean Void Sequenceof Listof List U False
Any Boolean Void Sequenceof Listof List U False Number Values
Mutable-HashTable Immutable-HashTable))
(for-label (only-in math/matrix Matrix))
(for-label (only-in graph (matrix-graph? g:matrix-graph?)))
(for-label (only-in data/gen-queue/fifo mk-empty-fifo))
(for-label typed/graph))
@title{Typed Interface for the Generic Graph Library}
@ -121,6 +122,27 @@ matrix graphs.
Graph properties are not supported.
@subsection{Basic Graph Functions}
@defproc[(bfs [g Graph] [source Any]) (Values (Mutable-HashTable Any Number)
(Mutable-HashTable Any Any))]{}
@defproc[(bfs/generalized [g Graph]
[source Any]
[#:init-queue Q Any (mk-empty-fifo)]
[#:break break? (-> Graph Any Any Any Boolean)
(λ (G src from to) #f)]
[#:init init (U (-> Graph Any Void) Void) void]
[#:visit? custom-visit?-fn (U (-> Graph Any Any Any Boolean) False)
(λ (G src from to) #f)]
[#:discover discover (-> Graph Any Any Any Any Any)
(λ (G s u v acc) acc)]
[#:visit visit (-> Graph Any Any Any Any)
(λ (G s v acc) acc)]
[#:return finish (-> Graph Any Any Any)
(λ (G s acc) acc)]
) Any]{}
@defproc[(fewest-vertices-path [g Graph] [source Any] [target Any]) (U (Listof Any) False)]{}
@section{License}
Like the generic graph library, this library is licensed under the Apache