https://github.com/juliuste/sainte_lague.rs
Sainte-Laguë method for seat distribution used in multiple parliamentary elections around the world.
https://github.com/juliuste/sainte_lague.rs
election library
Last synced: 3 months ago
JSON representation
Sainte-Laguë method for seat distribution used in multiple parliamentary elections around the world.
- Host: GitHub
- URL: https://github.com/juliuste/sainte_lague.rs
- Owner: juliuste
- License: isc
- Created: 2020-05-24T10:46:09.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-05-20T22:13:24.000Z (about 3 years ago)
- Last Synced: 2025-03-23T04:41:13.416Z (4 months ago)
- Topics: election, library
- Language: Rust
- Homepage:
- Size: 17.6 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# sainte_lague
A rust implementation of the **[Sainte-Laguë](https://en.wikipedia.org/wiki/Webster/Sainte-Lagu%C3%AB_method)** (also known as **Webster** or **Schepers**) method. Parliament seat allocation algorithm used in multiple countries such as Germany, Latvia, New Zealand etc…
*Attention: Since some countries (like Latvia or Norway) use a modification of the algorithm instead of this vanilla version, you should check your country's electoral legislature. Furthermore, I don't take any responsibility for the accuracy of the calculated numbers, even though I'm pretty confident with my implementation.*
[](https://crates.io/crates/sainte_lague)
[](license)## Example
```rust
use sainte_lague::distribute;// …
#[test]
fn german_bundestag_2013() {
let votes = [41.5, 25.7, 8.6, 8.4];
let seats = 631;let distribution = distribute(&votes, &seats, &false);
let parliament = vec![311, 193, 64, 63];
assert_eq!(distribution, Ok(parliament));
}
// …
```**Full documentation on [docs.rs](https://docs.rs/sainte_lague/).**
## Similar projects
- [`largest-remainder-method`](https://crates.io/crates/largest-remainder-method) - A rust implementation of the Hare-Niemeyer / Hamilton / largest remainder method
## Contributing
If you found a bug or want to propose a feature, feel free to visit [the issues page](https://github.com/juliuste/sainte_lague.rs/issues).