Crates.io | flag-algebra |
lib.rs | flag-algebra |
version | 0.4.0 |
source | src |
created_at | 2019-01-23 14:51:54.561897 |
updated_at | 2024-06-24 19:15:58.807265 |
description | An implementation of Razborov's flag algebras |
homepage | |
repository | https://github.com/avangogo/rust-flag-algebra |
max_upload_size | |
id | 110221 |
size | 308,123 |
A generic implementation of flag algebras.
Flag algebras is a framework used to produce computer-assisted proofs of some inequalities in combinatorics, relying on Semi-Definite Programming.
// Proving that in any graph, at least 1/4 of the triples
// are triangles or independent sets.
use flag_algebra::*;
use flag_algebra::flags::Graph;
// Work on the graphs of size 3.
let basis = Basis::new(3);
// Define useful flags.
let k3 = flag(&Graph::new(3, &[(0, 1), (1, 2), (2, 0)])); // Triangle
let e3 = flag(&Graph::new(3, &[])); // Independent set of size 3
// Definition of the optimization problem.
let pb = Problem::<i64, _> {
// Constraints
ineqs: vec![total_sum_is_one(basis), flags_are_nonnegative(basis)],
// Use all relevant Cauchy-Schwarz inequalities.
cs: basis.all_cs(),
// Minimize density of triangle plus density of independent of size 3.
obj: k3 + e3,
};
// Write the correspondind SDP program in "goodman.sdpa".
// This program can then be solved by CSDP. The answer would be 0.25.
pb.write_sdpa("goodman").unwrap();
This library can currently do the following.
This library is generic. To use a kind combinatorial objects as flags (e.g. graphs), it suffices to implement the Flag trait for the corresponding Rust datatype.
Currently, Flag is implemented for Graphs, Oriented graphs, Directed graphs and edge-colored graphs with some fixed number of colors.
Beside implementing directly [Flag] for your own types, two mechanisms help
to define flag classes based on an existing flag class F
.
N
is an integer identifier, Colored<F, N>
is the type for flags of type F
where the vertices are further colored in N
different colors.
Colored<F, N>
automatically implement Flag
when F
does.See [Type], [Basis] and [QFlag].
The Type<F:Flag>
structure identifies a
"type" σ in the sense of flag algebras (i.e. a completely labeled flag)
is represented by an object.
The Basis<F:Flag>
structure corresponds to a couple (n, σ)
and identifies the set of σ-flags of size n.
The structure QFlag
License: GPL-3.0