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.

116 lines
5.0 KiB

  1. #lang scribble/manual
  2. @(require (for-label (only-in typed/racket
  3. require/typed require/typed/provide
  4. Any Boolean Void Sequenceof Listof List U False
  5. Mutable-HashTable Immutable-HashTable))
  6. (for-label (only-in graph (graph? g:graph?)))
  7. (for-label typed/graph))
  8. @title{Typed Interface for the Generic Graph Library}
  9. @author[@author+email["Sergiu Ivanov" "sivanov@colimite.fr"]]
  10. @defmodule[typed/graph]
  11. This library provides an incomplete typed interface to the
  12. @hyperlink["https://docs.racket-lang.org/graph/index.html"]{generic graph
  13. library}. The following parts are @bold{not currently covered}:
  14. @itemlist[
  15. @item{generic graph interface,}
  16. @item{generic queues (from the package @racket[gen-queue-lib]),}
  17. @item{macros.}
  18. ]
  19. I may work on adding these in the future, but it is low priority for me as of
  20. 2021-12-21. Feel free to contribute!
  21. @section{Bug reporting}
  22. If you find a bug, first try running your code directly with the graph library,
  23. in untyped Racket. If the bug persists, you should probably report it to the
  24. maintainer of the graph library directly. If unsure, report the bug to me.
  25. @section{Contributing}
  26. As of 2021, GitHub is owned by Microsoft, so I prefer keeping this library on
  27. a different platform.
  28. Do feel free to submit patches to me by E-mail: I will try my best to review
  29. and apply them within a reasonable time frame. More details on contributing in
  30. the
  31. @hyperlink["https://git.marvid.fr/scolobb/typed-graph/src/branch/master/README.md#submitting-patches"]{README}.
  32. @section{Technical details}
  33. Typed Racket includes very useful primitives @racket[require/typed] and
  34. @racket[require/typed/provide]. However, we cannot use this technique with the
  35. graph library. The solution which works consists in wrapping the opaque graph
  36. structure into another structure, which will therefore be a uniform container
  37. for all kinds of graph implementations provided by the library.
  38. This solution comes from Alex Knauth's answer
  39. @hyperlink["https://stackoverflow.com/a/65416020"]{answer on Stack Overflow}.
  40. This page also contains a technical explanation of the issue.
  41. @section{Exported types}
  42. This section lists the types this library gives to re-exported functions.
  43. The subsections correspond to the sections of the documentation of the generic
  44. graph library.
  45. @defidform[Graph]{
  46. The opaque type corresponding to the predicate @racketlink[g:graph? "graph?"].
  47. }
  48. @subsection{Generic Graph Interface}
  49. @defproc[(has-vertex? [g Graph] [v Any]) Boolean]{}
  50. @defproc[(has-edge? [g Graph] [u Any] [v Any]) Boolean]{}
  51. @defproc[(vertex=? [g Graph] [u Any] [v Any]) Boolean]{}
  52. @defproc[(add-vertex! [g Graph] [v Any]) Void]{}
  53. @defproc[(remove-vertex! [g Graph] [v Any]) Void]{}
  54. @defproc[(rename-vertex! [g Graph] [old Any] [new Any]) Void]{}
  55. @defproc[(add-edge! [g Graph] [u Any] [v Any] [weight Any 'default-value]) Void]{}
  56. @defproc[(add-directed-edge! [g Graph] [u Any] [v Any] [weight Any 'default-value]) Void]{}
  57. @defproc[(remove-edge! [g Graph] [u Any] [v Any]) Void]{}
  58. @defproc[(remove-directed-edge! [g Graph] [u Any] [v Any]) Void]{}
  59. @defproc[(get-vertices [g Graph]) (Listof Any)]{}
  60. @defproc[(in-vertices [g Graph]) (Sequenceof Any)]{}
  61. @defproc[(get-neighbors [g Graph] [v Any]) (Listof Any)]{}
  62. @defproc[(in-neighbors [g Graph] [v Any]) (Sequenceof Any)]{}
  63. @defproc[(get-edges [g Graph]) (U (Listof (List Any Any)) (Listof (List Any Any Any)))]{}
  64. @defproc[(in-edges [g Graph]) (Sequenceof (U (List Any Any) (List Any Any Any)))]{}
  65. @defproc[(edge-weight [g Graph] [u Any] [v Any] [#:default default Any +inf.0]) Any]{}
  66. @defproc[(transpose [g Graph]) Graph]{}
  67. @defproc[(graph-copy [g Graph]) Graph]{}
  68. @defproc[(graph-union! [g Graph] [other Graph]) Void]{}
  69. @subsection{Graph Constructors}
  70. @defproc[(unweighted-graph? [g Graph]) Boolean]{}
  71. @defproc[(unweighted-graph/undirected [edges (Listof (List Any Any))]) Graph]{}
  72. @defproc[(unweighted-graph/directed [edges (Listof (List Any Any))]) Graph]{}
  73. @defproc[(unweighted-graph/adj [edges (Listof (Listof Any))]) Graph]{}
  74. @defproc[(weighted-graph? [g Graph]) Boolean]{}
  75. @defproc[(weighted-graph/undirected [edges (Listof (List Any Any Any))]) Graph]{}
  76. @defproc[(weighted-graph/directed [edges (Listof (List Any Any Any))]) Graph]{}
  77. @defproc[(undirected-graph [edges (Listof (List Any Any))] [wgts (Listof Any) #f]) Graph]{}
  78. @defproc[(directed-graph [edges (Listof (List Any Any))] [wgts (Listof Any) #f]) Graph]{}
  79. @defproc[(matrix-graph? [g Graph]) Boolean]{}
  80. @section{License}
  81. Like the generic graph library, this library is licensed under the Apache
  82. License, Version 2.0 (the "License"); you may not use this file except in
  83. compliance with the License. You may obtain a copy of the License at
  84. @hyperlink["http://www.apache.org/licenses/LICENSE-2.0"]{http://www.apache.org/licenses/LICENSE-2.0}
  85. Unless required by applicable law or agreed to in writing, software distributed
  86. under the License is distributed on an @bold{"as is" basis, without warranties
  87. or conditions of any kind}, either express or implied. See the License for the
  88. specific language governing permissions and limitations under the License.