https://github.com/j-christl/ocaml-havelhakimi
Functional implementation of the Havel-Hakimi algorithm in OCaml
https://github.com/j-christl/ocaml-havelhakimi
discrete-mathematics functional-programming graph-theory havel-hakimi-algorithm ocaml
Last synced: 8 months ago
JSON representation
Functional implementation of the Havel-Hakimi algorithm in OCaml
- Host: GitHub
- URL: https://github.com/j-christl/ocaml-havelhakimi
- Owner: j-christl
- Created: 2018-12-23T13:02:35.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-02T21:35:30.000Z (almost 7 years ago)
- Last Synced: 2025-01-24T01:11:11.123Z (10 months ago)
- Topics: discrete-mathematics, functional-programming, graph-theory, havel-hakimi-algorithm, ocaml
- Language: OCaml
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OCaml-HavelHakimi
Functional implementation of the Havel-Hakimi algorithm (https://en.wikipedia.org/wiki/Havel%E2%80%93Hakimi_algorithm) in OCaml
```ocaml
val havel_hakimi : int list -> bool =
```
## Examples
### Example 1
```ocaml
# havel_hakimi [1;1;2;3;4;4;5];;
5 4 4 3 2 1 1
3 3 2 1 0 1 (unsorted)
3 3 2 1 1 0
2 1 0 1 0 (unsorted)
2 1 1 0 0
0 0 0 0 (unsorted)
0 0 0 0
- : bool = true
```
### Example 2
```ocaml
# havel_hakimi [2;2;2;2;3];;
3 2 2 2 2
1 1 1 2 (unsorted)
2 1 1 1
0 0 1 (unsorted)
1 0 0
-1 0 (unsorted)
0 -1
- : bool = false
```