Low-level bindings for nauty and Traces
This crate provides ffi bindings for nauty and Traces. Nauty and Traces are implementations of algorithms for computing graph automorphisms.
Usage
Add the following lines to your Cargo.toml:
[]
= "0.3"
By default, you need a C compiler installed on your system. See the Features section for alternatives.
Caveats
-
You can use either the version of nauty and Traces that is bundled with this crate or a local installation. Both options have advantages and disadvantages. See the Features section below.
-
Some C macros have no direct equivalent.
-
Instead of using
DYNALLSTAT
andDYNALLOC
you can createVec
s or arrays. -
Use the
empty_graph
function in place ofEMPTY_GRAPH
. -
Most
DEFAULT
-type macros have been replaced with implementations of the rustDefault
trait. Forsparsenauty
default options useoptionsblk::default_sparse()
. -
The
SparseGraph
struct helps with creating sparse graphs. A&mut SparseGraph
can be converted to thesparsegraph
used by nauty and Traces.
-
Examples
The following program prints the generators for the automorphism
groups of n-vertex polygons. It is a pretty literal translation of the
nautyex2
C program that is part of the nauty and Traces bundle.
use *;
use ;
use c_int;
Features
See The Cargo Book for guidance on features.
Default features
-
bundled
: Use the version of nauty and Traces that comes bundled with this crate. This requires a C compiler on your system.Deactivate this feature to use a custom installation. In that case, you can only free memory allocated by nauty and Traces if this crate is linked to the same libc. Use the
libc
feature to generate the required bindings. -
tls
: Ensure thread-safety in the bundled library. Corresponds to compiling nauty and Traces withUSE_TLS
defined. -
libc
: nauty and Traces sometimes allocate memory internally, for example in thenauty_to_sg
function. This feature enable bindings toDYNFREE
andSG_FREE
, which are needed to deallocate this memory again. Note that this can only be done safely if nauty and Traces are linked to the same libc as this crate.
Non-default features
Activating the following features may make the generated binaries faster but less portable.
-
clz
: Allow using thelzcnt
processor instruction, if available. -
popcnt
: Allow using thepopcnt
processor instruction, if available. -
native
: Allow processor instructions that are specific to the current hardware. Impliesclz
andpopcnt
.