7 releases

0.3.0 Mar 27, 2022
0.2.4 Nov 3, 2021
0.2.3 Feb 18, 2021
0.2.2 Dec 15, 2020
0.1.0 Nov 24, 2020

#1449 in Algorithms

23 downloads per month
Used in 2 crates

MIT/Apache

27KB
349 lines

bigs

A BIpartite Graph Sampler

A tool to generate regular bipartite graphs. A bipartite graph is a set of variables and constraints (named like this because of SAT problems) together with a set of edges. Right now, only regular graphs can be sampled. That is, graphs with the same degree for all variables and the same for all constraints.

Example

use bigs::Sampler;
use rand::thread_rng;

let sampler = Sampler::builder()
    .number_of_variables(10)
    .number_of_constraints(6)
    .variable_degree(3)
    .constraint_degree(5)
    .build();

let graph = sampler.sample_with(&mut thread_rng());
let other_graph = sampler.sample_with(&mut thread_rng());

lib.rs:

BIpartite Graph Sampler.

A tool to generate regular bipartite graphs. A bipartite graph is a set of variables and constraints (named like this because of SAT problems) together with a set of edges. Right now, only regular graphs can be sampled. That is, graphs with the same degree for all variables and the same for all constraints.

Quick start

Graphs are sampled using a Sampler which are instanciated via the builder method. Then, any random number generator can be used to sample a Graph.

use bigs::Sampler;
use rand::thread_rng;

let sampler = Sampler::builder()
    .number_of_variables(10)
    .number_of_constraints(6)
    .variable_degree(3)
    .constraint_degree(5)
    .build() // Returns an error if the parameters are invalid.
    .unwrap();

let graph = sampler.sample_with(&mut thread_rng());
let other_graph = sampler.sample_with(&mut thread_rng());

Dependencies

~1.8–2.7MB
~53K SLoC