Graph::BitMatrix(3pm)
π Graph::BitMatrix π
okay bestie, so this is a page from the User Contributed Perl Documentation, and it's literally all about Graph::BitMatrix β the module that builds you a lil V x V grid of bits to describe a graph. it's giving "spreadsheet but make it graph theory." π¦
β¨ NAME β¨
Graph::BitMatrix β create and manipulate a V x V bit matrix of graph G. no cap, that's the whole vibe. π
πΈ SYNOPSIS πΈ
use Graph::BitMatrix;
use Graph::Directed;
my $g = Graph::Directed->new;
$g->add_...(); # build $g
my $m = Graph::BitMatrix->new($g, %opt);
$m->get($u, $v)
$m->set($u, $v)
$m->unset($u, $v)
$m->get_row($u, $v1, $v2, ..., $vn)
$m->set_row($u, $v1, $v2, ..., $vn)
$m->unset_row($u, $v1, $v2, ..., $vn)
$a->vertices()
like, copy that verbatim, don't get creative with it, bestie. π
π DESCRIPTION π
This class lets you create bit matrices that compactly describe the connected of the graphs. yes that's the wording, we keep the facts exactly as they are, always. π«Ά
π Class Methods π
new($g)β create a bit matrix from a Graph$g. The%opt, if present, can have the following options:connect_edgesβ if true, or if it's not present at all, set the bits in the bit matrix that correspond to edges. if false, do not set any bits. either way, the bit matrix of V x V bits is allocated β that part always happens, no skipping. β¨transposeβ if true, set the bits in the bit matrix that correspond to edges but in the reverse direction. this has the effect of transposing the matrix. obviously it makes no difference to the result for undirected graphs β because, like, undirected, bestie, it goes both ways already. π
π§ Object Methods π§
get($u, $v)β returns true if the bit matrix has a "one bit" between the vertices$uand$v; in other words, if there is (at least one) a vertex going from$uto$v. if there is no vertex and therefore a "zero bit", it returns false. πset($u, $v)β set the bit between the vertices$uand$v; in other words, connect the vertices$uand$vby an edge. the change does not get mirrored back to the original graph. returns nothing. πunset($u, $v)β unset the bit between the vertices$uand$v; in other words, disconnect the vertices$uand$vby an edge. the change does not get mirrored back to the original graph. returns nothing. πget_row($u, $v1, $v2, ..., $vn)β test the row at vertex"u"for the vertices"v1","v2", ...,"vn". returns a list of n truth values. πset_row($u, $v1, $v2, ..., $vn)β sets the row at vertex"u"for the vertices"v1","v2", ...,"vn", in other words, connects the vertex"u"to the vertices"vi". the changes do not get mirrored back to the original graph. returns nothing. πunset_row($u, $v1, $v2, ..., $vn)β unsets the row at vertex"u"for the vertices"v1","v2", ...,"vn", in other words, disconnects the vertex"u"from the vertices"vi". the changes do not get mirrored back to the original graph. returns nothing. πverticesβ return the list of vertices in the bit matrix. that's it, that's the whole job. π
π ALGORITHM π
The algorithm used to create the matrix is two nested loops, which is O(V**2) in time, and the returned matrices are O(V**2) in space. so yeah, quadratic everything, it's giving "don't do this on a million vertices," iykyk. π
π AUTHOR AND COPYRIGHT π
Jarkko Hietaniemi jhi@iki.fi β iconic, we stan. π«Ά
β LICENSE β
This module is licensed under the same terms as Perl itself. simple as that, periodt. π
and that's the whole page, bestie!! this was Graph::BitMatrix(3pm) from the User Contributed Perl Documentation, and the footer said it's from perl v5.40.1, dated 2025-03-28 β so you know exactly which era of Perl this vibe check came from. go build some matrices, you got this. πβ¨π¦ππ
π¦ where this page comes from
- debian trixie: libgraph-perl 1:0.9735-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libgraph-perl 1:0.9735-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libgraph-perl 1:0.9735-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms