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 $u and $v; in other words, if there is (at least one) a vertex going from $u to $v. if there is no vertex and therefore a "zero bit", it returns false. πŸ“
  • set($u, $v) β€” set the bit between the vertices $u and $v; in other words, connect the vertices $u and $v by an edge. the change does not get mirrored back to the original graph. returns nothing. πŸ™ˆ
  • unset($u, $v) β€” unset the bit between the vertices $u and $v; in other words, disconnect the vertices $u and $v by 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. πŸ’€


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