Graph::Nauty(3pm)
π Graph::Nauty β the perl bindings for Nauty, bestie π
okay so this is a page from the User Contributed Perl Documentation section of the manual, and it's all about Graph::Nauty, no cap. it's giving "i want to know if your graph and my graph are literally the same graph" energy and honestly? iconic.
β¨ NAME β¨
Graph::Nauty β Perl bindings for Nauty π¦
πΈ SYNOPSIS πΈ
like, here's the whole vibe up front, bestie:
use Graph::Nauty qw(
are_isomorphic
automorphism_group_size
canonical_order
orbits
);
use Graph::Undirected;
my $A = Graph::Undirected->new;
my $B = Graph::Undirected->new;
# Create graphs here
# Get the size of the automorphism group:
print automorphism_group_size( $A );
# Get automorphism group orbits:
print orbits( $A );
# Check whether two graphs are isomorphs:
print are_isomorphic( $A, $B );
# Get canonical order of vertices:
print canonical_order( $A );
that's it. that's the whole flex. π
π DESCRIPTION π
so Graph::Nauty is the little bridge that lets you talk to Nauty, which is a whole set of procedures for figuring out the automorphism group of a vertex-coloured graph, and for testing graphs to see if they're isomorphic. π₯
rn, Graph::Nauty only supports Graph::Undirected β so directed graphs? not today, bestie, it does not handle them. and both colored vertices and edges get accounted for when it's determining equivalence classes. periodt.
π Vertex color π
so Graph lets you use literally any data type as a graph vertex, which means there's not much you can just infer about them automatically. π for now, Graph::Nauty by default stringifies every vertex (using Perl's "" operator) and splits them into equivalence classes. but if you need different behavior? you can pass a custom anonymous subroutine inside an option hash, like:
print orbits( $A, sub { return length $_[0] } );
the subroutine gets a vertex as its 0th parameter, and it's expected to return a string, or honestly anything stringifiable. slay.
and in subroutines where the order of the returned vertices actually matters, you can pass a second anonymous subroutine to order the vertices inside each of the equivalence classes:
print orbits( $A, sub { return length $_[0] }, sub { return "$_[0]" } );
if you don't give an ordering subroutine, stringification (Perl's "" operator) is what's used by default. lowkey convenient.
π Edge color π
edge colors get generated from the Graph edge attributes. the complete hash of each edge's attributes is stringified (deterministically, bestie β we're not doing chaos here) and that's what's used to divide edges into equivalence classes. π§
β Working storage size β
Nauty needs working storage, and no, it does not allocate it by itself. Graph::Nauty follows the advice in the Nauty user guide and allocates the recommended amount of memory β but for certain graphs, that still might not be enough. π
to control that, you can use $Graph::Nauty::worksize to set the size of memory, in the units of Nauty's setword.
like, genuinely keep this one in your back pocket if things get weird with a chunky graph.
π INSTALLING π
building and installing Graph::Nauty from source requires a shared library and C headers for Nauty, which you can download from:
<https://users.cecs.anu.edu.au/~bdm/nauty/>
both the library and the C headers have to be installed to locations that are visible to Perl's C compiler. no shortcuts, bestie. π«Ά
π¦ SEE ALSO π¦
for the description of Nauty, refer to <http://pallini.di.uniroma1.it>.
π AUTHOR π
Andrius Merkys, <mailto:merkys@cpan.org>
π COPYRIGHT AND LICENSE π
Copyright (C) 2020 by Andrius Merkys
Graph::Nauty is distributed under the BSD-3-Clause license.
and that's the whole page!! this was documented by the perl crew, perl v5.40.0, dated 2025-02-12, on a Graph::Nauty(3pm) tip. mwah. πβ¨
π¦ where this page comes from
- debian trixie: libgraph-nauty-perl 0.5.3-1 Β· BSD-3-Clause
- ubuntu questing: libgraph-nauty-perl 0.5.3-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms